tests(packer): cleanup cloud init files.

This commit is contained in:
Alexandre Pujol 2024-03-15 14:55:46 +00:00
parent c3c61a9270
commit 3fc4c29968
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
12 changed files with 79 additions and 76 deletions

View File

@ -55,25 +55,24 @@ packages:
- terminator - terminator
runcmd: runcmd:
# Regenerate grub.cfg # Regenerate grub.cfg
- [ grub-mkconfig, -o, /boot/grub/grub.cfg ] - grub-mkconfig -o /boot/grub/grub.cfg
# Remove swapfile # Remove swapfile
- [ swapoff, -a ] - swapoff -a
- [ rm, -rf, /swap/ ] - rm -rf /swap/
- [ sed, -e, "/swap/d", -i, /etc/fstab ] - sed -e "/swap/d" -i /etc/fstab
# Enable core services # Enable core services
- [ systemctl, enable, apparmor ] - systemctl enable apparmor
- [ systemctl, enable, auditd ] - systemctl enable auditd
- [ systemctl, enable, gdm ] - systemctl enable gdm
- [ systemctl, enable, NetworkManager ] - systemctl enable NetworkManager
- [ systemctl, enable, rngd ] - systemctl enable rngd
- [ systemctl, enable, systemd-timesyncd.service ] - systemctl enable avahi-daemon
- systemctl enable systemd-timesyncd.service
write_files: write_files:
# Enable AppArmor in kernel parameters # Enable AppArmor in kernel parameters
- path: /etc/default/grub - path: /etc/default/grub
append: true append: true

View File

@ -46,9 +46,10 @@ packages:
# Install Graphical Interface # Install Graphical Interface
- plasma-meta - plasma-meta
- sddm - sddm
- ark
- dolphin - dolphin
- konsole - konsole
- ark - okular
# Install Applications # Install Applications
- firefox - firefox
@ -56,25 +57,24 @@ packages:
- terminator - terminator
runcmd: runcmd:
# Regenerate grub.cfg # Regenerate grub.cfg
- [ grub-mkconfig, -o, /boot/grub/grub.cfg ] - grub-mkconfig -o /boot/grub/grub.cfg
# Remove swapfile # Remove swapfile
- [ swapoff, -a ] - swapoff -a
- [ rm, -rf, /swap/ ] - rm -rf /swap/
- [ sed, -e, "/swap/d", -i, /etc/fstab ] - sed -e "/swap/d" -i /etc/fstab
# Enable core services # Enable core services
- [ systemctl, enable, apparmor ] - systemctl enable apparmor
- [ systemctl, enable, auditd ] - systemctl enable auditd
- [ systemctl, enable, sddm ] - systemctl enable sddm
- [ systemctl, enable, NetworkManager ] - systemctl enable NetworkManager
- [ systemctl, enable, rngd ] - systemctl enable rngd
- [ systemctl, enable, systemd-timesyncd.service ] - systemctl enable avahi-daemon
- systemctl enable systemd-timesyncd.service
write_files: write_files:
# Enable AppArmor in kernel parameters # Enable AppArmor in kernel parameters
- path: /etc/default/grub - path: /etc/default/grub
append: true append: true

View File

@ -37,37 +37,21 @@ packages:
- wget - wget
runcmd: runcmd:
# Regenerate grub.cfg # Regenerate grub.cfg
- [ grub-mkconfig, -o, /boot/grub/grub.cfg ] - grub-mkconfig -o /boot/grub/grub.cfg
# Remove swapfile # Remove swapfile
- [ swapoff, -a ] - swapoff -a
- [ rm, -rf, /swap/ ] - rm -rf /swap/
- [ sed, -e, "/swap/d", -i, /etc/fstab ] - sed -e "/swap/d" -i /etc/fstab
# Enable core services # Enable core services
- [ systemctl, enable, apparmor ] - systemctl enable apparmor
- [ systemctl, enable, auditd ] - systemctl enable auditd
- [ systemctl, enable, rngd ] - systemctl enable rngd
- [ systemctl, enable, systemd-timesyncd.service ] - systemctl enable systemd-timesyncd.service
write_files: write_files:
# Network configuration
- path: /etc/systemd/network/20-wired.network
owner: 'root:root'
permissions: '0644'
content: |
[Match]
Name=en*
[Network]
DHCP=yes
[DHCPv4]
RouteMetric=10
# Enable AppArmor in kernel parameters # Enable AppArmor in kernel parameters
- path: /etc/default/grub - path: /etc/default/grub
append: true append: true
@ -79,3 +63,23 @@ 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
# Network configuration
- path: /etc/systemd/network/20-wired.network
owner: "root:root"
permissions: "0644"
content: |
[Match]
Name=en*
[Network]
DHCP=yes
[DHCPv4]
RouteMetric=10

View File

@ -145,9 +145,9 @@ trim() {
truncate --size=0 /swap/swapfile truncate --size=0 /swap/swapfile
fi fi
_msg "Fill root filesystem with 0 to reduce box size" # _msg "Fill root filesystem with 0 to reduce box size"
dd if=/dev/zero of=/EMPTY bs=1M || true # dd if=/dev/zero of=/EMPTY bs=1M || true
rm -f /EMPTY # rm -f /EMPTY
# Block until the empty file has been removed, otherwise, Packer will # Block until the empty file has been removed, otherwise, Packer will
# try to kill the box while the disk is still full and that is bad. # try to kill the box while the disk is still full and that is bad.

View File

@ -37,15 +37,21 @@ runcmd:
- apt-get install -y -t bookworm-backports golang-go - apt-get install -y -t bookworm-backports golang-go
write_files: write_files:
# Add backports repository
- path: /etc/apt/sources.list - path: /etc/apt/sources.list
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"
permissions: '0644' permissions: "0644"
content: | content: |
[Match] [Match]
Name=en* Name=en*

View File

@ -37,7 +37,7 @@ runcmd:
- apt-get install -y -t bookworm-backports golang-go - apt-get install -y -t bookworm-backports golang-go
write_files: write_files:
# Add backports repository
- path: /etc/apt/sources.list - path: /etc/apt/sources.list
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

View File

@ -35,7 +35,7 @@ runcmd:
- apt-get install -y -t bookworm-backports golang-go - apt-get install -y -t bookworm-backports golang-go
write_files: write_files:
# Add backports repository
- path: /etc/apt/sources.list - path: /etc/apt/sources.list
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
@ -48,8 +48,8 @@ write_files:
# Network configuration # Network configuration
- path: /etc/systemd/network/20-wired.network - path: /etc/systemd/network/20-wired.network
owner: 'root:root' owner: "root:root"
permissions: '0644' permissions: "0644"
content: | content: |
[Match] [Match]
Name=en* Name=en*

View File

@ -22,7 +22,7 @@ main() {
install -Dm0644 $SRC/site.local /etc/apparmor.d/tunables/multiarch.d/site.local 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-update /usr/bin/aa-update
install -Dm0755 $SRC/aa-log-clean /usr/bin/aa-log-clean install -Dm0755 $SRC/aa-log-clean /usr/bin/aa-log-clean
cat $SRC/parser.conf >> /etc/apparmor/parser.conf cat $SRC/parser.conf >>/etc/apparmor/parser.conf
chown -R "$SUDO_USER:$SUDO_USER" "/home/$SUDO_USER/.config/" chown -R "$SUDO_USER:$SUDO_USER" "/home/$SUDO_USER/.config/"
case "$DISTRIBUTION" in case "$DISTRIBUTION" in
arch) pacman --noconfirm -U $SRC/*.pkg.tar.zst ;; arch) pacman --noconfirm -U $SRC/*.pkg.tar.zst ;;

View File

@ -28,7 +28,6 @@ packages:
- vim - vim
write_files: write_files:
# Set some bash aliases # Set some bash aliases
- path: /home/${username}/.bashrc - path: /home/${username}/.bashrc
append: true append: true

View File

@ -42,7 +42,6 @@ snap:
- install snapd-desktop-integration - install snapd-desktop-integration
runcmd: runcmd:
# Remove default filesystem and related tools not used with the suggested # Remove default filesystem and related tools not used with the suggested
# storage layout. These may yet be required if different partitioning schemes # storage layout. These may yet be required if different partitioning schemes
# are used. # are used.
@ -64,7 +63,6 @@ runcmd:
- apt-get -y autoremove - apt-get -y autoremove
write_files: write_files:
# Setup shared directory # Setup shared directory
- path: /etc/fstab - path: /etc/fstab
append: true append: true
@ -72,8 +70,8 @@ write_files:
0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1 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"
content: | content: |
[Match] [Match]
Name=en* Name=en*

View File

@ -42,7 +42,6 @@ snap:
- install snapd-desktop-integration - install snapd-desktop-integration
runcmd: runcmd:
# Remove default filesystem and related tools not used with the suggested # Remove default filesystem and related tools not used with the suggested
# storage layout. These may yet be required if different partitioning schemes # storage layout. These may yet be required if different partitioning schemes
# are used. # are used.
@ -64,7 +63,6 @@ runcmd:
- apt-get -y autoremove - apt-get -y autoremove
write_files: write_files:
# Setup shared directory # Setup shared directory
- path: /etc/fstab - path: /etc/fstab
append: true append: true
@ -72,8 +70,8 @@ write_files:
0a31bc478ef8e2461a4b1cc10a24cc4 /home/user/Projects/apparmor.d virtiofs defaults 0 1 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"
content: | content: |
[Match] [Match]
Name=en* Name=en*

View File

@ -32,7 +32,6 @@ packages:
- vim - vim
write_files: write_files:
# Setup shared directory # Setup shared directory
- path: /etc/fstab - path: /etc/fstab
append: true append: true
@ -41,8 +40,8 @@ write_files:
# Network configuration # Network configuration
- path: /etc/systemd/network/20-wired.network - path: /etc/systemd/network/20-wired.network
owner: 'root:root' owner: "root:root"
permissions: '0644' permissions: "0644"
content: | content: |
[Match] [Match]
Name=en* Name=en*