From cc3b76d7a413eabafd821169bcdd5cc07658c652 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Tue, 18 Jul 2023 22:23:47 +0100 Subject: [PATCH] test: add vm image for ubuntu-desktop. --- tests/boxes.yml | 6 ++ .../packer/init/ubuntu-desktop.user-data.yml | 73 +++++++++++++++++++ tests/packer/main.pkr.hcl | 1 + tests/packer/ubuntu.pkr.hcl | 36 +++++++++ 4 files changed, 116 insertions(+) create mode 100644 tests/packer/init/ubuntu-desktop.user-data.yml diff --git a/tests/boxes.yml b/tests/boxes.yml index 09017f8a..c1f91d6f 100644 --- a/tests/boxes.yml +++ b/tests/boxes.yml @@ -14,6 +14,12 @@ boxes: ram: '6144' cpu: '6' + - name: ubuntu-desktop + box: aa-ubuntu-desktop + uefi: true + ram: '6144' + cpu: '6' + - name: ubuntu-server box: aa-ubuntu-server uefi: true diff --git a/tests/packer/init/ubuntu-desktop.user-data.yml b/tests/packer/init/ubuntu-desktop.user-data.yml new file mode 100644 index 00000000..3abbc289 --- /dev/null +++ b/tests/packer/init/ubuntu-desktop.user-data.yml @@ -0,0 +1,73 @@ +#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 gnome-3-38-2004 + - install gtk-common-themes + - install snap-store + - install snapd-desktop-integration + +runcmd: + + # Let NetworkManager handle network + - rm /etc/netplan/* + - >- + printf "network:\n version: 2\n renderer: NetworkManager" > /etc/netplan/01-network-manager.yaml + + # 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 remove btrfs-progs cryptsetup* lvm2 xfsprogs + + # Remove other packages present by default in Ubuntu Server but not + # normally present in Ubuntu Desktop. + - >- + apt-get -y remove + ubuntu-server ubuntu-server-minimal + 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 + + # Keep cloud-init, as it performs some of the installation on first boot. + - apt-get -y install cloud-init + + # Finally, remove things only installed as dependencies of other things + # we have already removed. + - apt-get -y autoremove diff --git a/tests/packer/main.pkr.hcl b/tests/packer/main.pkr.hcl index ca198342..ddb7c3a5 100644 --- a/tests/packer/main.pkr.hcl +++ b/tests/packer/main.pkr.hcl @@ -8,6 +8,7 @@ build { "source.qemu.archlinux-kde", "source.qemu.debian-server", "source.qemu.opensuse-kde", + "source.qemu.ubuntu-desktop", "source.qemu.ubuntu-server", ] diff --git a/tests/packer/ubuntu.pkr.hcl b/tests/packer/ubuntu.pkr.hcl index 5c5355a7..5375604d 100644 --- a/tests/packer/ubuntu.pkr.hcl +++ b/tests/packer/ubuntu.pkr.hcl @@ -37,3 +37,39 @@ source "qemu" "ubuntu-server" { ) } } + +source "qemu" "ubuntu-desktop" { + disk_image = true + iso_url = "https://cloud-images.ubuntu.com/${var.release.ubuntu.codename}/current/${var.release.ubuntu.codename}-server-cloudimg-amd64.img" + iso_checksum = "file:https://cloud-images.ubuntu.com/${var.release.ubuntu.codename}/current/SHA256SUMS" + iso_target_path = "${var.iso_dir}/ubuntu-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}" + } + ) + } +}