diff --git a/ubuntu/Makefile b/ubuntu/Makefile index f49d675f..1f74dd4a 100644 --- a/ubuntu/Makefile +++ b/ubuntu/Makefile @@ -6,6 +6,12 @@ PACKER ?= packer PACKER_LOG ?= 0 export PACKER_LOG +SERIES ?= jammy +URL ?= http://releases.ubuntu.com +SUMS ?= SHA256SUMS + +ISO=$(shell wget -O- -q ${URL}/${SERIES}/${SUMS} | grep live-server | cut -d'*' -f2) + .PHONY: all clean all: custom-cloudimg.tar.gz @@ -29,15 +35,18 @@ OVMF_VARS.fd: /usr/share/OVMF/OVMF_VARS.fd cp -v $< $@ custom-cloudimg.tar.gz: check-deps clean - ${PACKER} init . && ${PACKER} build -only='cloudimg.*' . + ${PACKER} init . && ${PACKER} build -only='cloudimg.*' -var ubuntu_series=${SERIES} . custom-ubuntu.tar.gz: check-deps clean seeds-flat.iso OVMF_VARS.fd \ packages/custom-packages.tar.gz - ${PACKER} init . && ${PACKER} build -only=qemu.flat . + ${PACKER} init . && ${PACKER} build -only=qemu.flat \ + -var ubuntu_series=${SERIES} \ + -var ubuntu_iso=${ISO} . custom-ubuntu-lvm.dd.gz: check-deps clean seeds-lvm.iso OVMF_VARS.fd - ${PACKER} init . && ${PACKER} build -only=qemu.lvm . - + ${PACKER} init . && ${PACKER} build -only=qemu.lvm \ + -var ubuntu_series=${SERIES} \ + -var ubuntu_lvm_iso=${ISO} . clean: ${RM} -rf output-* custom-*.gz \ seeds-flat.iso seeds-lvm.iso seeds-cloudimg.iso \ diff --git a/ubuntu/README.md b/ubuntu/README.md index 292382bb..0d73707a 100644 --- a/ubuntu/README.md +++ b/ubuntu/README.md @@ -129,6 +129,20 @@ Note: ubuntu-lvm.pkr.hcl and ubuntu-flat.pkr.hcl are configured to run Packer in Installation is non-interactive. Note that the installation will attempt an SSH connection to the QEMU VM where the newly-built image is being booted. This is the final provisioning step in the process. Packer uses SSH to discover that the image has, in fact, booted, so there may be a number of failed tries -- over 3-5 minutes -- until the connection is successful. This is normal behavior for packer. +### Makefile Parameters + +#### PACKER_LOG +Enable (1) or Disable (0) verbose packer logs. The default value is set to 0. + +#### SERIES +Specify the Ubuntu Series to build. The default value is set to Jammy. + +#### URL +The URL prefix for mirror that is hosting the ISO images for a given series. The default value is set to http://releases.ubuntu.com. ISO images are expected to be under URL/SERIES/. + +#### SUMS +The file name for the checksums file. The default value is set to SHA256SUMS. + ### Default Username The default username is ```ubuntu``` diff --git a/ubuntu/ubuntu-flat.pkr.hcl b/ubuntu/ubuntu-flat.pkr.hcl index aea17632..173febfc 100644 --- a/ubuntu/ubuntu-flat.pkr.hcl +++ b/ubuntu/ubuntu-flat.pkr.hcl @@ -1,9 +1,3 @@ -variable "flat_filename" { - type = string - default = "custom-ubuntu.tar.gz" - description = "The filename of the tarball to produce" -} - source "qemu" "flat" { boot_command = ["e", "", "autoinstall ---"] boot_wait = "2s" @@ -12,9 +6,9 @@ source "qemu" "flat" { format = "raw" headless = var.headless http_directory = var.http_directory - iso_checksum = "file:http://releases.ubuntu.com/jammy/SHA256SUMS" - iso_target_path = "packer_cache/ubuntu.iso" - iso_url = "https://releases.ubuntu.com/jammy/ubuntu-22.04.3-live-server-amd64.iso" + iso_checksum = "file:http://releases.ubuntu.com/${var.ubuntu_series}/SHA256SUMS" + iso_target_path = "packer_cache/${var.ubuntu_series}.iso" + iso_url = "https://releases.ubuntu.com/${var.ubuntu_series}/${var.ubuntu_iso}" memory = 2048 qemuargs = [ ["-vga", "qxl"], @@ -25,7 +19,7 @@ source "qemu" "flat" { ["-drive", "if=pflash,format=raw,file=OVMF_VARS.fd"], ["-drive", "file=output-flat/packer-flat,if=none,id=drive0,cache=writeback,discard=ignore,format=raw"], ["-drive", "file=seeds-flat.iso,format=raw,cache=none,if=none,id=drive1,readonly=on"], - ["-drive", "file=packer_cache/ubuntu.iso,if=none,id=cdrom0,media=cdrom"] + ["-drive", "file=packer_cache/${var.ubuntu_series}.iso,if=none,id=cdrom0,media=cdrom"] ] shutdown_command = "sudo -S shutdown -P now" ssh_handshake_attempts = 500 diff --git a/ubuntu/ubuntu-flat.variables.pkr.hcl b/ubuntu/ubuntu-flat.variables.pkr.hcl new file mode 100644 index 00000000..c939e016 --- /dev/null +++ b/ubuntu/ubuntu-flat.variables.pkr.hcl @@ -0,0 +1,12 @@ +variable "flat_filename" { + type = string + default = "custom-ubuntu.tar.gz" + description = "The filename of the tarball to produce" +} + +variable "ubuntu_iso" { + type = string + default = "ubuntu-22.04.3-live-server-amd64.iso" + description = "The ISO name to build the image from" +} + diff --git a/ubuntu/ubuntu-lvm.pkr.hcl b/ubuntu/ubuntu-lvm.pkr.hcl index 5819c989..c94f7c58 100644 --- a/ubuntu/ubuntu-lvm.pkr.hcl +++ b/ubuntu/ubuntu-lvm.pkr.hcl @@ -6,9 +6,9 @@ source "qemu" "lvm" { format = "raw" headless = var.headless http_directory = var.http_directory - iso_checksum = "file:http://releases.ubuntu.com/jammy/SHA256SUMS" - iso_target_path = "packer_cache/ubuntu.iso" - iso_url = "https://releases.ubuntu.com/jammy/ubuntu-22.04.3-live-server-amd64.iso" + iso_checksum = "file:http://releases.ubuntu.com/${var.ubuntu_series}/SHA256SUMS" + iso_target_path = "packer_cache/${var.ubuntu_series}.iso" + iso_url = "https://releases.ubuntu.com/${var.ubuntu_series}/${var.ubuntu_lvm_iso}" memory = 2048 qemuargs = [ ["-vga", "qxl"], @@ -19,7 +19,7 @@ source "qemu" "lvm" { ["-drive", "if=pflash,format=raw,file=OVMF_VARS.fd"], ["-drive", "file=output-lvm/packer-lvm,if=none,id=drive0,cache=writeback,discard=ignore,format=raw"], ["-drive", "file=seeds-lvm.iso,format=raw,cache=none,if=none,id=drive1,readonly=on"], - ["-drive", "file=packer_cache/ubuntu.iso,if=none,id=cdrom0,media=cdrom"] + ["-drive", "file=packer_cache/${var.ubuntu_series}.iso,if=none,id=cdrom0,media=cdrom"] ] shutdown_command = "sudo -S shutdown -P now" ssh_handshake_attempts = 500 diff --git a/ubuntu/ubuntu-lvm.variables.pkr.hcl b/ubuntu/ubuntu-lvm.variables.pkr.hcl new file mode 100644 index 00000000..842b19ef --- /dev/null +++ b/ubuntu/ubuntu-lvm.variables.pkr.hcl @@ -0,0 +1,6 @@ +variable "ubuntu_lvm_iso" { + type = string + default = "ubuntu-22.04.3-live-server-amd64.iso" + description = "The ISO name to build the image from" +} +