diff --git a/README.md b/README.md index 746ffca2..f782b3b6 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,8 @@ Linux and Windows hosts, but feedback on other platforms is always welcome. Due to difficulties with Packer packaging, this VM is frequently built with the latest version of Packer available directly from Hashicorp. Check the -`main.pkr.hcl` file for the current minimum version required. +`main.pkr.hcl` file for the current minimum version required. To install the +required plugins, run `packer init .` within the `cs-vm-build/packer` directory. Once the prerequisites are installed, change into the `cs-vm-build/packer` directory and execute `packer build -only "*.mint" .`. This will take a diff --git a/packer/config.plist b/packer/config.plist new file mode 100644 index 00000000..a9025471 --- /dev/null +++ b/packer/config.plist @@ -0,0 +1,111 @@ + + + + + ConfigurationVersion + 2 + Debug + + DebugLog + + + Display + + ConsoleFont + Menlo + ConsoleFontSize + 12 + ConsoleTheme + Default + DisplayCard + virtio-ramfb-gl + DisplayDownscaler + linear + DisplayFitScreen + + DisplayRetina + + DisplayUpscaler + linear + + Drives + + + DriveName + drive0 + ImagePath + image.qcow2 + ImageType + disk + InterfaceType + virtio + + + Info + + Icon + ubuntu + IconCustom + + Notes + + + Input + + InputLegacy + + + Networking + + NetworkCard + virtio-net-pci + NetworkMode + emulated + + Printing + + Sharing + + ClipboardSharing + + DirectoryName + + DirectorySharing + + Usb3Support + + UsbRedirectMax + 3 + + Sound + + SoundCard + intel-hda + SoundEnabled + + + System + + Architecture + aarch64 + BootDevice + + CPU + cortex-a72 + CPUCount + 0 + ForceMulticore + + JITCacheSize + 0 + MachineProperties + highmem=off + Memory + 4096 + SystemUUID + 1A9B879C-CDA8-4728-AA9A-4717B646E9AC + Target + virt + + + diff --git a/packer/http/meta-data b/packer/http/meta-data new file mode 100644 index 00000000..e69de29b diff --git a/packer/http/network-config b/packer/http/network-config new file mode 100644 index 00000000..e69de29b diff --git a/packer/http/oem-preseed.cfg b/packer/http/oem-preseed.cfg index c2f7392d..04d4261d 100644 --- a/packer/http/oem-preseed.cfg +++ b/packer/http/oem-preseed.cfg @@ -66,6 +66,7 @@ ubiquity ubiquity/success_command string svcfile="/target/etc/systemd/system/ssh echo "ExecStart=/usr/bin/apt-get -y install openssh-server" >> "$svcfile"; \ echo "ExecStartPost=/bin/systemctl disable ssh-install.service" >> "$svcfile"; \ echo "ExecStartPost=/bin/rm /etc/systemd/system/ssh-install.service" >> "$svcfile"; \ + echo "TimeoutSec=300" >> "$svcfile"; \ echo "[Install]" >> "$svcfile"; \ echo "WantedBy=multi-user.target" >> "$svcfile"; \ in-target systemctl enable ssh-install.service diff --git a/packer/http/user-data b/packer/http/user-data new file mode 100644 index 00000000..fbb0733e --- /dev/null +++ b/packer/http/user-data @@ -0,0 +1,42 @@ +#cloud-config +autoinstall: + version: 1 + codecs: + install: true + identity: + hostname: ubuntu + username: oem + password: $6$250qJD2ObtCZAp.v$8nYXTi6MJo.Qd3dQNQgcz136tbrfza3p8RqXF47T1A1PYlwJ91ug5sJAMy.kCAlWRyQJb8PptIFQ0EmipHltk. + network: + version: 2 + ethernets: + eth0: + dhcp4: true + match: + name: en* + packages: + - ansible + - bash-completion +# - cinnamon-desktop-environment +# - gdm3 +# - gnome-initial-setup + - git + - linux-image-virtual +# - ubuntucinnamon-wallpapers-noble + - vim + shutdown: reboot + source: + id: ubuntu-server + ssh: + install-server: true + storage: + layout: + name: lvm + sizing-policy: all + timezone: "US/Eastern" + late-commands: + - curtin in-target -- locale-gen en_US.UTF-8 + - curtin in-target -- apt-get -y --autoremove --purge remove linux-generic linux-image-generic linux-headers* linux-modules-extra* linux-tools* linux-firmware + - curtin in-target -- apt-get -y install cinnamon-desktop-environment gdm3 gnome-initial-setup ubuntucinnamon-wallpapers-noble + - curtin in-target -- git clone -b aarch64-support https://github.com/ripleymj/cs-vm-build + - curtin in-target -- bash -c "export LC_ALL=en_US.UTF-8; cs-vm-build/scripts/oem-build" diff --git a/packer/http/vendor-data b/packer/http/vendor-data new file mode 100644 index 00000000..e69de29b diff --git a/packer/main.pkr.hcl b/packer/main.pkr.hcl index 1237ae19..a0fc46f4 100644 --- a/packer/main.pkr.hcl +++ b/packer/main.pkr.hcl @@ -1,6 +1,10 @@ packer { - required_version = ">= 1.7.0" + required_version = ">= 1.9.0" required_plugins { + qemu = { + source = "github.com/hashicorp/qemu" + version = "~> 1" + } virtualbox = { version = "~> 1" source = "github.com/hashicorp/virtualbox" @@ -8,6 +12,59 @@ packer { } } +source "qemu" "kvm" { + cpus = 4 + memory = 4096 + disk_size = 20480 + machine_type = "q35" + accelerator = "kvm" + + format = "qcow2" + headless = "${var.headless}" + http_directory = "http" +# qemu_binary = "qemu-system-aarch64" + +# efi_firmware_code = "${var.qemu_firmware_directory}/AAVMF_CODE.fd" +# efi_firmware_vars = "${var.qemu_firmware_directory}/AAVMF_VARS.fd" + qemuargs = [ + ["-boot", "strict=off"], + ["-cpu", "max"], + ["-display", var.headless ? "none" : "gtk"], + ["-device", "virtio-rng-pci"], + ["-device", "virtio-gpu"], + ["-device", "nec-usb-xhci,id=xhci"], + ["-device", "usb-kbd,bus=xhci.0"], + ["-device", "usb-tablet,bus=xhci.0"] + ] + qemu_img_args { + create = ["-o", "preallocation=falloc"] + convert = ["-o", "compression_type=zstd"] + } + disk_cache = "unsafe" + disk_compression = "true" + disk_detect_zeroes = "unmap" + disk_discard = "unmap" + disk_interface = "virtio" + net_device = "virtio-net" + ssh_username = var.ssh_user + ssh_password = var.ssh_pass + ssh_timeout = "100m" + + boot_wait = var.aarch64_boot_wait + boot_command = [ + # Enter the command line + "c", + # Configure the kernel + "linux /casper/vmlinuz ", + " autoinstall 'ds=nocloud;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/'", + " ", + # Configure initrd & boot + "initrd /casper/initrd ", + "boot" + ] + shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff" +} + source "virtualbox-iso" "base-build" { cpus = 2 memory = 4096 @@ -53,7 +110,7 @@ source "virtualbox-iso" "base-build" { "initrd /casper/initrd.lz", "boot" ] - shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff" + shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S userdel -rf oem; echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff" vboxmanage = [ ["modifyvm", "{{ .Name }}", "--audioin", "off"], @@ -113,7 +170,25 @@ build { ] } + source "source.qemu.kvm" { + name = "ubuntu-aarch64" + vm_name = "image.qcow2" + iso_url = "${local.ubuntu_aarch64_info.mirror_url}/${local.ubuntu_aarch64_info.iso_file}" + iso_checksum = "file:${local.ubuntu_aarch64_info.mirror_url}/SHA256SUMS" + output_directory = "${local.artifact_dir_prefix}ubuntu-aarch64" + } + + source "source.qemu.kvm" { + name = "ubuntu-amd64" + vm_name = "image.qcow2" + iso_url = "${local.ubuntu_aarch64_info.mirror_url}/${local.ubuntu_amd64_info.iso_file}" + iso_checksum = "file:${local.ubuntu_amd64_info.mirror_url}/SHA256SUMS" + output_directory = "${local.artifact_dir_prefix}ubuntu-amd64" + } + provisioner "shell" { + only = ["virtualbox-iso.base-build"] + execute_command = "echo 'oem' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'" environment_vars = [ "DEBIAN_FRONTEND=noninteractive" diff --git a/packer/ubuntu-version.auto.pkrvars.hcl b/packer/ubuntu-version.auto.pkrvars.hcl index 510f6cfd..f30e5616 100644 --- a/packer/ubuntu-version.auto.pkrvars.hcl +++ b/packer/ubuntu-version.auto.pkrvars.hcl @@ -1,4 +1,4 @@ ubuntu_version = { - version = "jammy" - patched_version = "22.04.5" + version = "noble" + patched_version = "24.04.3" } diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index ff4f0bb1..644b6ef0 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -71,15 +71,49 @@ variable "vm_name" { default = "JMU CS" } +variable "aarch64_boot_wait" { + type = string + default = "25s" + description = "The length of time to wait after boot before entering commands" + + validation { + condition = can(regex("\\d+s", var.aarch64_boot_wait)) + error_message = "The value should be a number of seconds followed by 's'." + } +} + +variable "qemu_accelerator" { + type = string + default = "tcg" + description = <