From bac96582939bdbd589a2798cabbfb451efc2ea7c Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Fri, 8 Mar 2024 13:13:00 +0000 Subject: [PATCH] test(packer): configure shared directory directly in the image. This way, we do not always need to use vagrant to start a vm. --- tests/Vagrantfile | 2 +- tests/packer/init/archlinux-gnome.user-data.yml | 6 ++++++ tests/packer/init/archlinux-kde.user-data.yml | 6 ++++++ tests/packer/init/debian-kde.user-data.yml | 16 ++++------------ tests/packer/init/debian-server.user-data.yml | 6 ++++++ tests/packer/init/init.sh | 2 +- tests/packer/init/opensuse-kde.user-data.yml | 13 +++++++++++-- tests/packer/init/ubuntu-desktop.user-data.yml | 6 ++++++ tests/packer/init/ubuntu-desktop24.user-data.yml | 6 ++++++ tests/packer/init/ubuntu-server.user-data.yml | 6 ++++++ 10 files changed, 53 insertions(+), 16 deletions(-) diff --git a/tests/Vagrantfile b/tests/Vagrantfile index 7b4a8fee6..fce3a3f0d 100644 --- a/tests/Vagrantfile +++ b/tests/Vagrantfile @@ -26,7 +26,7 @@ Vagrant.configure("2") do |config| srv.vm.post_up_message = instance.to_yaml srv.vm.synced_folder '.', '/vagrant', disabled: true if !ENV['AA_INTEGRATION'] - srv.vm.synced_folder '../', '/home/user/Projects/apparmor.d', type: 'virtiofs' + srv.vm.synced_folder '../', '/home/user/Projects/apparmor.d', type: 'virtiofs', mount: false end # Configure Libvirt provider diff --git a/tests/packer/init/archlinux-gnome.user-data.yml b/tests/packer/init/archlinux-gnome.user-data.yml index 59cb0976c..3fa13b169 100644 --- a/tests/packer/init/archlinux-gnome.user-data.yml +++ b/tests/packer/init/archlinux-gnome.user-data.yml @@ -85,3 +85,9 @@ write_files: 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/archlinux-kde.user-data.yml b/tests/packer/init/archlinux-kde.user-data.yml index 5f6f17e0b..923533bd1 100644 --- a/tests/packer/init/archlinux-kde.user-data.yml +++ b/tests/packer/init/archlinux-kde.user-data.yml @@ -86,3 +86,9 @@ write_files: 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/debian-kde.user-data.yml b/tests/packer/init/debian-kde.user-data.yml index 80c1e5f7c..84524fde1 100644 --- a/tests/packer/init/debian-kde.user-data.yml +++ b/tests/packer/init/debian-kde.user-data.yml @@ -42,16 +42,8 @@ write_files: append: true content: deb http://deb.debian.org/debian bookworm-backports main contrib non-free - # Network configuration - - path: /etc/systemd/network/20-wired.network - owner: 'root:root' - permissions: '0644' + # Setup shared directory + - path: /etc/fstab + append: true content: | - [Match] - Name=en* - - [Network] - DHCP=yes - - [DHCPv4] - RouteMetric=10 + 0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1 diff --git a/tests/packer/init/debian-server.user-data.yml b/tests/packer/init/debian-server.user-data.yml index 38e3cad36..2f4a86ef6 100644 --- a/tests/packer/init/debian-server.user-data.yml +++ b/tests/packer/init/debian-server.user-data.yml @@ -40,6 +40,12 @@ write_files: append: true content: deb http://deb.debian.org/debian bookworm-backports main contrib non-free + # Setup shared directory + - path: /etc/fstab + append: true + content: | + 0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1 + # Network configuration - path: /etc/systemd/network/20-wired.network owner: 'root:root' diff --git a/tests/packer/init/init.sh b/tests/packer/init/init.sh index e2127663b..66b49f38a 100644 --- a/tests/packer/init/init.sh +++ b/tests/packer/init/init.sh @@ -15,7 +15,7 @@ readonly SRC=/tmp/src readonly DISTRIBUTION main() { - install -dm0750 -o "$SUDO_USER" -g "$SUDO_USER" "/home/$SUDO_USER/Projects/" "/home/$SUDO_USER/.config/" + 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" diff --git a/tests/packer/init/opensuse-kde.user-data.yml b/tests/packer/init/opensuse-kde.user-data.yml index e334c16c6..4e39bab2a 100644 --- a/tests/packer/init/opensuse-kde.user-data.yml +++ b/tests/packer/init/opensuse-kde.user-data.yml @@ -27,7 +27,16 @@ packages: - rsync - vim -runcmd: +write_files: # Set some bash aliases - - echo '[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases' >> /home/${username}/.bashrc + - path: /home/${username}/.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/ubuntu-desktop.user-data.yml b/tests/packer/init/ubuntu-desktop.user-data.yml index 937b84d20..d0a691d8f 100644 --- a/tests/packer/init/ubuntu-desktop.user-data.yml +++ b/tests/packer/init/ubuntu-desktop.user-data.yml @@ -65,6 +65,12 @@ runcmd: write_files: + # Setup shared directory + - path: /etc/fstab + append: true + content: | + 0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1 + - path: /etc/systemd/network/20-wired.network owner: 'root:root' permissions: '0644' diff --git a/tests/packer/init/ubuntu-desktop24.user-data.yml b/tests/packer/init/ubuntu-desktop24.user-data.yml index 937b84d20..d0a691d8f 100644 --- a/tests/packer/init/ubuntu-desktop24.user-data.yml +++ b/tests/packer/init/ubuntu-desktop24.user-data.yml @@ -65,6 +65,12 @@ runcmd: write_files: + # Setup shared directory + - path: /etc/fstab + append: true + content: | + 0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1 + - path: /etc/systemd/network/20-wired.network owner: 'root:root' permissions: '0644' diff --git a/tests/packer/init/ubuntu-server.user-data.yml b/tests/packer/init/ubuntu-server.user-data.yml index 64fecc855..851399069 100644 --- a/tests/packer/init/ubuntu-server.user-data.yml +++ b/tests/packer/init/ubuntu-server.user-data.yml @@ -33,6 +33,12 @@ packages: write_files: + # Setup shared directory + - path: /etc/fstab + append: true + content: | + 0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1 + # Network configuration - path: /etc/systemd/network/20-wired.network owner: 'root:root'