From d163b4b4ae53fd1540bb4ca830240f61660ef37b Mon Sep 17 00:00:00 2001 From: Kyle Laker Date: Thu, 2 May 2024 22:56:49 -0400 Subject: [PATCH] Add basic Ubuntu 24.04 auto-install --- packer/http/autoinstall.yaml | 35 +++++++++++ packer/http/oem-preseed.cfg | 85 -------------------------- packer/main.pkr.hcl | 15 +---- packer/ubuntu-version.auto.pkrvars.hcl | 4 +- 4 files changed, 40 insertions(+), 99 deletions(-) create mode 100644 packer/http/autoinstall.yaml delete mode 100644 packer/http/oem-preseed.cfg diff --git a/packer/http/autoinstall.yaml b/packer/http/autoinstall.yaml new file mode 100644 index 00000000..3230b477 --- /dev/null +++ b/packer/http/autoinstall.yaml @@ -0,0 +1,35 @@ +#cloud-config +autoinstall: + version: 1 + interactive-sections: [] + locale: 'en_US.UTF-8' + refresh-installer: + update: true + keyboard: + layout: us + apt: + mirror-selection: + primary: + - arches: [i386, amd64] + uri: 'http://mirror.cs.jmu.edu/pub/ubuntu' + - arches: [arm64] + uri: 'http://ports.ubuntu.com/ubuntu-ports' + fallback: abort + packages: + - oem-config + storage: + layout: + name: direct + identity: + hostname: jmucs + realname: 'OEM User' + username: oem + password: $1$.WsfKhkz$G/3ZFe1ZGQrJJJ7GoJ.vY. + ssh: + install-server: true + codecs: + install: true + oem: + install: true + updates: all + shutdown: reboot diff --git a/packer/http/oem-preseed.cfg b/packer/http/oem-preseed.cfg deleted file mode 100644 index c2f7392d..00000000 --- a/packer/http/oem-preseed.cfg +++ /dev/null @@ -1,85 +0,0 @@ -d-i debconf/priority string critical -ubiquity oem-config/enable boolean true -ubiquity ubiquity/use_nonfree boolean true - -### Localization -d-i debian-installer/locale string en_US.UTF-8 -d-i console-setup/ask_detect boolean false -d-i console-setup/layoutcode string us -ubiquity countrychooser/shortlist select US -ubiquity languagechooser/language-name select English -ubiquity localechooser/supported-locales multiselect en_US.UTF-8 - -ubiquity oem-config/id string JMUCS - -# Keyboard selection. -d-i keyboard-configuration/ask_detect boolean false -d-i keyboard-configuration/layoutcode string us - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic - -# In addition, you'll need to specify the method to use. -# The presently available methods are: -# - regular: use the usual partition types for your architecture -# - lvm: use LVM to partition the disk -# - crypto: use LVM within an encrypted partition -d-i partman-auto/method string regular - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -### Clock and time zone setup -d-i clock-setup/utc boolean true -d-i time/zone string US/Eastern -d-i clock-setup/ntp boolean true - -# Any hostname and domain names assigned from dhcp take precedence over -# values set here. However, setting the values still prevents the questions -# from being shown, even if values come from dhcp. -d-i netcfg/get_hostname string cs-vm -d-i netcfg/get_domain string localdomain - -# To create a normal user account. -d-i passwd/user-fullname string oem -d-i passwd/username string oem -d-i passwd/user-password-crypted password $1$.WsfKhkz$G/3ZFe1ZGQrJJJ7GoJ.vY. - -# Configure systemd to trigger the installation of openssh-server following -# reboot to allow packer to access the machine to complete provisioning. See -# https://forums.linuxmint.com/viewtopic.php?t=236838 for details. - -ubiquity ubiquity/success_command string svcfile="/target/etc/systemd/system/ssh-install.service"; \ - touch "$svcfile"; \ - echo "[Unit]" >> "$svcfile"; \ - echo "After=network-online.target" >> "$svcfile"; \ - echo "Requires=network-online.target" >> "$svcfile"; \ - echo "[Service]" >> "$svcfile"; \ - echo "ExecStartPre=/usr/bin/apt-get update" >> "$svcfile"; \ - 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 "[Install]" >> "$svcfile"; \ - echo "WantedBy=multi-user.target" >> "$svcfile"; \ - in-target systemctl enable ssh-install.service - -# This will prevent the installer from ejecting the CD during the reboot, -# which is useful in some situations. -d-i cdrom-detect/eject boolean true - -# complete the installation automatically. -ubiquity ubiquity/summary note -# Avoid that last message about the install being complete. -d-i finish-install/reboot_in_progress note - -ubiquity ubiquity/reboot boolean true - -#Cause an installer crash toward the end -#ubiquity ubiquity/hide_slideshow boolean true diff --git a/packer/main.pkr.hcl b/packer/main.pkr.hcl index 0c4b2578..86e77c60 100644 --- a/packer/main.pkr.hcl +++ b/packer/main.pkr.hcl @@ -39,19 +39,10 @@ source "virtualbox-iso" "base-build" { "c", # Configure the kernel "linux /casper/vmlinuz", - " boot=casper", - " auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/oem-preseed.cfg", - " automatic-ubiquity only-ubiquity", - " debug-ubiquity oem-config/enable=true", - " keymap=us fsck.mode=skip", - " noprompt splash --", - # Configure initrd & boot - # Different distributions name (and compress) the initrd differently. Fortunately, - # GRUB is mostly smart and if the file doesn't exist, it just won't apply that directive. - # So to prevent duplication, we specify both and let GRUB ignore the wrong one. + " autoinstall cloud-config-url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinstall.yaml", + " --", "initrd /casper/initrd", - "initrd /casper/initrd.lz", - "boot" + "boot" ] shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff" diff --git a/packer/ubuntu-version.auto.pkrvars.hcl b/packer/ubuntu-version.auto.pkrvars.hcl index ed6eeecf..3a15ad7b 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.4" + version = "noble" + patched_version = "24.04" }