From 7c7e897d452c947ad02b6b6045f7233562c71b42 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sat, 27 Jan 2024 19:34:41 +0000 Subject: [PATCH] test(packer): add debian-kde & ubuntu 24.04 tests image. --- tests/boxes.yml | 12 +++ tests/packer/builds.pkr.hcl | 7 +- tests/packer/debian.pkr.hcl | 36 +++++++++ tests/packer/init/debian-kde.user-data.yml | 57 +++++++++++++ .../init/ubuntu-desktop24.user-data.yml | 79 +++++++++++++++++++ tests/packer/main.pkr.hcl | 4 + tests/packer/ubuntu.pkr.hcl | 36 +++++++++ 7 files changed, 229 insertions(+), 2 deletions(-) create mode 100644 tests/packer/init/debian-kde.user-data.yml create mode 100644 tests/packer/init/ubuntu-desktop24.user-data.yml diff --git a/tests/boxes.yml b/tests/boxes.yml index 6b82d1d6..bab03cfa 100644 --- a/tests/boxes.yml +++ b/tests/boxes.yml @@ -26,6 +26,12 @@ boxes: ram: '6144' cpu: '6' + - name: ubuntu-desktop24 + box: aa-ubuntu-desktop24 + uefi: true + ram: '6144' + cpu: '6' + - name: ubuntu-server box: aa-ubuntu-server uefi: true @@ -50,6 +56,12 @@ boxes: ram: '6144' cpu: '6' + - name: debian-kde + box: aa-debian-kde + uefi: true + ram: '6144' + cpu: '6' + - name: opensuse-kde box: aa-opensuse-kde uefi: true diff --git a/tests/packer/builds.pkr.hcl b/tests/packer/builds.pkr.hcl index f275b2c2..105adfb1 100644 --- a/tests/packer/builds.pkr.hcl +++ b/tests/packer/builds.pkr.hcl @@ -7,10 +7,13 @@ build { "source.qemu.archlinux-gnome", "source.qemu.archlinux-kde", "source.qemu.archlinux-server", - "source.qemu.debian-server", "source.qemu.debian-gnome", + "source.qemu.debian-kde", + "source.qemu.debian-server", + "source.qemu.opensuse-gnome", "source.qemu.opensuse-kde", "source.qemu.ubuntu-desktop", + "source.qemu.ubuntu-desktop24", "source.qemu.ubuntu-server", "source.qemu.ubuntu-server24", ] @@ -34,7 +37,7 @@ build { } provisioner "file" { - only = ["qemu.debian-server", "qemu.debian-gnome", "qemu.ubuntu-server", "qemu.ubuntu-server24", "qemu.ubuntu-desktop"] + only = ["qemu.debian-server", "qemu.debian-gnome", "qemu.debian-kde", "qemu.ubuntu-server", "qemu.ubuntu-server24", "qemu.ubuntu-desktop", "qemu.ubuntu-desktop24"] destination = "/tmp/src/" sources = ["${path.cwd}/../apparmor.d_${var.version}-1_amd64.deb"] } diff --git a/tests/packer/debian.pkr.hcl b/tests/packer/debian.pkr.hcl index 11e8c89f..4a572d6b 100644 --- a/tests/packer/debian.pkr.hcl +++ b/tests/packer/debian.pkr.hcl @@ -73,3 +73,39 @@ source "qemu" "debian-gnome" { ) } } + +source "qemu" "debian-kde" { + disk_image = true + iso_url = "https://cdimage.debian.org/images/cloud/${var.release.debian.codename}/latest/debian-${var.release.debian.version}-genericcloud-amd64.qcow2" + iso_checksum = "file:https://cdimage.debian.org/images/cloud/${var.release.debian.codename}/latest/SHA512SUMS" + iso_target_path = "${var.iso_dir}/debian-cloudimg-amd64.img" + cpus = 4 + memory = 2048 + disk_size = var.disk_size + accelerator = "kvm" + headless = true + ssh_username = var.username + ssh_password = var.password + ssh_port = 22 + ssh_wait_timeout = "1000s" + disk_compression = true + disk_detect_zeroes = "unmap" + disk_discard = "unmap" + output_directory = "${var.output}/" + vm_name = "${var.prefix}${source.name}.qcow2" + boot_wait = "10s" + firmware = var.firmware + shutdown_command = "echo ${var.password} | sudo -S /sbin/shutdown -hP now" + cd_label = "cidata" + cd_content = { + "meta-data" = "" + "user-data" = templatefile("${path.cwd}/packer/init/${source.name}.user-data.yml", + { + username = "${var.username}" + password = "${var.password}" + ssh_key = file("${var.ssh_publickey}") + hostname = "${var.prefix}${source.name}" + } + ) + } +} diff --git a/tests/packer/init/debian-kde.user-data.yml b/tests/packer/init/debian-kde.user-data.yml new file mode 100644 index 00000000..80c1e5f7 --- /dev/null +++ b/tests/packer/init/debian-kde.user-data.yml @@ -0,0 +1,57 @@ +#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: + - apparmor-profiles + - auditd + - build-essential + - config-package-dev + - debhelper + - devscripts + - htop + - qemu-guest-agent + - spice-vdagent + - rsync + - vim + - task-kde-desktop + +runcmd: + - apt-get update -y + - apt-get install -y -t bookworm-backports golang-go + +write_files: + + - path: /etc/apt/sources.list + 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' + content: | + [Match] + Name=en* + + [Network] + DHCP=yes + + [DHCPv4] + RouteMetric=10 diff --git a/tests/packer/init/ubuntu-desktop24.user-data.yml b/tests/packer/init/ubuntu-desktop24.user-data.yml new file mode 100644 index 00000000..937b84d2 --- /dev/null +++ b/tests/packer/init/ubuntu-desktop24.user-data.yml @@ -0,0 +1,79 @@ +#cloud-config + +# Based on https://github.com/canonical/autoinstall-desktop + +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: + - ubuntu-desktop + - linux-generic-hwe-22.04 + - qemu-guest-agent + - spice-vdagent + - terminator + - apparmor-profiles + - build-essential + - config-package-dev + - debhelper + - devscripts + - golang-go + - rsync + +snap: + commands: + - install firefox + - install gtk-common-themes + - install snap-store + - install snapd-desktop-integration + +runcmd: + + # Remove default filesystem and related tools not used with the suggested + # storage layout. These may yet be required if different partitioning schemes + # are used. + - apt-get -y purge btrfs-progs cryptsetup* lvm2 xfsprogs + + # Remove other packages present by default in Ubuntu Server but not + # normally present in Ubuntu Desktop. + - >- + apt-get -y purge + ubuntu-server ubuntu-server-minimal netplan.io cloud-init + binutils byobu curl dmeventd finalrd gawk + kpartx mdadm ncurses-term needrestart open-iscsi + sg3-utils ssh-import-id sssd thin-provisioning-tools tmux + sosreport screen open-vm-tools motd-news-config lxd-agent-loader + landscape-common fonts-ubuntu-console ethtool + + # Finally, remove things only installed as dependencies of other things + # we have already removed. + - apt-get -y autoremove + +write_files: + + - path: /etc/systemd/network/20-wired.network + owner: 'root:root' + permissions: '0644' + content: | + [Match] + Name=en* + + [Network] + DHCP=yes + + [DHCPv4] + RouteMetric=10 diff --git a/tests/packer/main.pkr.hcl b/tests/packer/main.pkr.hcl index 742edf49..90844b5a 100644 --- a/tests/packer/main.pkr.hcl +++ b/tests/packer/main.pkr.hcl @@ -12,5 +12,9 @@ packer { source = "github.com/hashicorp/qemu" version = "~> 1" } + vagrant = { + source = "github.com/hashicorp/vagrant" + version = "~> 1" + } } } diff --git a/tests/packer/ubuntu.pkr.hcl b/tests/packer/ubuntu.pkr.hcl index 1be15ea8..6406ba5f 100644 --- a/tests/packer/ubuntu.pkr.hcl +++ b/tests/packer/ubuntu.pkr.hcl @@ -109,3 +109,39 @@ source "qemu" "ubuntu-desktop" { ) } } + +source "qemu" "ubuntu-desktop24" { + disk_image = true + iso_url = "https://cloud-images.ubuntu.com/${var.release.ubuntu24.codename}/current/${var.release.ubuntu24.codename}-server-cloudimg-amd64.img" + iso_checksum = "file:https://cloud-images.ubuntu.com/${var.release.ubuntu24.codename}/current/SHA256SUMS" + iso_target_path = "${var.iso_dir}/ubuntu-${var.release.ubuntu24.codename}-cloudimg-amd64.img" + cpus = 6 + memory = 4096 + disk_size = "40G" + accelerator = "kvm" + headless = true + ssh_username = var.username + ssh_password = var.password + ssh_port = 22 + ssh_wait_timeout = "10000s" + disk_compression = true + disk_detect_zeroes = "unmap" + disk_discard = "unmap" + output_directory = "${var.output}/" + vm_name = "${var.prefix}${source.name}.qcow2" + boot_wait = "10s" + firmware = var.firmware + shutdown_command = "echo ${var.password} | sudo -S /sbin/shutdown -hP now" + cd_label = "cidata" + cd_content = { + "meta-data" = "" + "user-data" = templatefile("${path.cwd}/packer/init/${source.name}.user-data.yml", + { + username = "${var.username}" + password = "${var.password}" + ssh_key = file("${var.ssh_publickey}") + hostname = "${var.prefix}${source.name}" + } + ) + } +}