test(packer): configure shared directory directly in the image.

This way, we do not always need to use vagrant to start a vm.
This commit is contained in:
Alexandre Pujol 2024-03-08 13:13:00 +00:00
parent c707b730ef
commit bac9658293
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
10 changed files with 53 additions and 16 deletions

2
tests/Vagrantfile vendored
View File

@ -26,7 +26,7 @@ Vagrant.configure("2") do |config|
srv.vm.post_up_message = instance.to_yaml srv.vm.post_up_message = instance.to_yaml
srv.vm.synced_folder '.', '/vagrant', disabled: true srv.vm.synced_folder '.', '/vagrant', disabled: true
if !ENV['AA_INTEGRATION'] 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 end
# Configure Libvirt provider # Configure Libvirt provider

View File

@ -85,3 +85,9 @@ write_files:
append: true append: true
content: | content: |
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases [[ -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

View File

@ -86,3 +86,9 @@ write_files:
append: true append: true
content: | content: |
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases [[ -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

View File

@ -42,16 +42,8 @@ write_files:
append: true append: true
content: deb http://deb.debian.org/debian bookworm-backports main contrib non-free content: deb http://deb.debian.org/debian bookworm-backports main contrib non-free
# Network configuration # Setup shared directory
- path: /etc/systemd/network/20-wired.network - path: /etc/fstab
owner: 'root:root' append: true
permissions: '0644'
content: | content: |
[Match] 0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1
Name=en*
[Network]
DHCP=yes
[DHCPv4]
RouteMetric=10

View File

@ -40,6 +40,12 @@ write_files:
append: true append: true
content: deb http://deb.debian.org/debian bookworm-backports main contrib non-free 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 # Network configuration
- path: /etc/systemd/network/20-wired.network - path: /etc/systemd/network/20-wired.network
owner: 'root:root' owner: 'root:root'

View File

@ -15,7 +15,7 @@ readonly SRC=/tmp/src
readonly DISTRIBUTION readonly DISTRIBUTION
main() { 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/.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/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 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/htoprc "/home/$SUDO_USER/.config/htop/htoprc"

View File

@ -27,7 +27,16 @@ packages:
- rsync - rsync
- vim - vim
runcmd: write_files:
# Set some bash aliases # 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

View File

@ -65,6 +65,12 @@ runcmd:
write_files: 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 - path: /etc/systemd/network/20-wired.network
owner: 'root:root' owner: 'root:root'
permissions: '0644' permissions: '0644'

View File

@ -65,6 +65,12 @@ runcmd:
write_files: 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 - path: /etc/systemd/network/20-wired.network
owner: 'root:root' owner: 'root:root'
permissions: '0644' permissions: '0644'

View File

@ -33,6 +33,12 @@ packages:
write_files: write_files:
# Setup shared directory
- path: /etc/fstab
append: true
content: |
0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1
# Network configuration # Network configuration
- path: /etc/systemd/network/20-wired.network - path: /etc/systemd/network/20-wired.network
owner: 'root:root' owner: 'root:root'