From 146bda8f454c4777e967ef41ff05eec1fe496933 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Mon, 7 Oct 2024 21:41:44 +0100 Subject: [PATCH] test(packer): as base image for the cosmic DE. --- tests/boxes.yml | 4 + .../init/archlinux-cosmic.user-data.yml | 90 +++++++++++++++++++ tests/packer/init/init.sh | 20 ++--- 3 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 tests/packer/init/archlinux-cosmic.user-data.yml diff --git a/tests/boxes.yml b/tests/boxes.yml index edda4109..ef037e07 100644 --- a/tests/boxes.yml +++ b/tests/boxes.yml @@ -18,6 +18,10 @@ boxes: box: aa-archlinux-xfce uefi: false + - name: arch-cosmic + box: aa-archlinux-cosmic + uefi: false + - name: arch-server box: aa-archlinux-server uefi: false diff --git a/tests/packer/init/archlinux-cosmic.user-data.yml b/tests/packer/init/archlinux-cosmic.user-data.yml new file mode 100644 index 00000000..442c3247 --- /dev/null +++ b/tests/packer/init/archlinux-cosmic.user-data.yml @@ -0,0 +1,90 @@ +#cloud-config + +hostname: ${hostname} +locale: en_IE +keyboard: + layout: ie + +ssh_pwauth: true +users: + - name: ${username} + plain_text_passwd: ${password} + shell: /bin/bash + ssh_authorized_keys: + - ${ssh_key} + lock_passwd: false + sudo: ALL=(ALL) NOPASSWD:ALL + +package_update: true +package_upgrade: true +package_reboot_if_required: false +packages: + # Install core packages + - apparmor + - audit + - base-devel + - firewalld + - qemu-guest-agent + - rng-tools + - spice-vdagent + + # Install usefull core packages + - bash-completion + - git + - htop + - man + - pass + - python-notify2 + - vim + - wget + + # Install basic services + - networkmanager + - cups + - cups-pdf + - system-config-printer + + # Install Graphical Interface + - cosmic + + # Install Applications + - firefox + - chromium + - terminator + +runcmd: + # Regenerate grub.cfg + - grub-mkconfig -o /boot/grub/grub.cfg + + # Remove swapfile + - swapoff -a + - rm -rf /swap/ + - sed -e "/swap/d" -i /etc/fstab + + # Enable core services + - systemctl enable apparmor + - systemctl enable auditd + - systemctl enable cosmic-greeter + - systemctl enable NetworkManager + - systemctl enable rngd + - systemctl enable avahi-daemon + - systemctl enable systemd-timesyncd.service + +write_files: + # Enable AppArmor in kernel parameters + - path: /etc/default/grub + append: true + content: | + GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT lsm=landlock,lockdown,yama,integrity,apparmor,bpf apparmor.debug=1" + + # Set some bash aliases + - path: /etc/skel/.bashrc + append: true + content: | + [[ -f ~/.bash_aliases ]] && source ~/.bash_aliases + + # Setup shared directory + - path: /etc/fstab + append: true + content: | + 0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1 diff --git a/tests/packer/init/init.sh b/tests/packer/init/init.sh index df300c0c..495d2f2a 100644 --- a/tests/packer/init/init.sh +++ b/tests/packer/init/init.sh @@ -15,16 +15,6 @@ readonly SRC=/tmp/src readonly DISTRIBUTION main() { - install -dm0750 -o "$SUDO_USER" -g "$SUDO_USER" "/home/$SUDO_USER/Projects/" "/home/$SUDO_USER/Projects/apparmor.d" "/home/$SUDO_USER/.config/" - install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/.bash_aliases "/home/$SUDO_USER/.bash_aliases" - install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/monitors.xml "/home/$SUDO_USER/.config/monitors.xml" - install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/htoprc "/home/$SUDO_USER/.config/htop/htoprc" - install -Dm0644 $SRC/site.local /etc/apparmor.d/tunables/multiarch.d/site.local - install -Dm0755 $SRC/aa-update /usr/bin/aa-update - install -Dm0755 $SRC/aa-log-clean /usr/bin/aa-log-clean - cat $SRC/parser.conf >>/etc/apparmor/parser.conf - chown -R "$SUDO_USER:$SUDO_USER" "/home/$SUDO_USER/.config/" - case "$DISTRIBUTION" in arch) pacman --noconfirm -U $SRC/*.pkg.tar.zst @@ -45,6 +35,16 @@ main() { ;; esac + + install -dm0750 -o "$SUDO_USER" -g "$SUDO_USER" "/home/$SUDO_USER/Projects/" "/home/$SUDO_USER/Projects/apparmor.d" "/home/$SUDO_USER/.config/" + install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/.bash_aliases "/home/$SUDO_USER/.bash_aliases" + install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/monitors.xml "/home/$SUDO_USER/.config/monitors.xml" + install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/htoprc "/home/$SUDO_USER/.config/htop/htoprc" + install -Dm0644 $SRC/site.local /etc/apparmor.d/tunables/multiarch.d/site.local + install -Dm0755 $SRC/aa-update /usr/bin/aa-update + install -Dm0755 $SRC/aa-log-clean /usr/bin/aa-log-clean + cat $SRC/parser.conf >>/etc/apparmor/parser.conf + chown -R "$SUDO_USER:$SUDO_USER" "/home/$SUDO_USER/.config/" } main "$@"