diff --git a/sles15/Makefile b/sles15/Makefile
index daa4c2f..f11ac05 100644
--- a/sles15/Makefile
+++ b/sles15/Makefile
@@ -7,6 +7,21 @@ PACKER_LOG ?= 0
export PACKER_LOG
ISO ?= SLE-15-SP4-Full-x86_64-GM-Media1.iso
TIMEOUT ?= 1h
+ARCH ?= x86_64
+
+ifeq ($(wildcard /usr/share/OVMF/OVMF_CODE.fd),)
+ OVMF_SFX ?= _4M
+else
+ OVMF_SFX ?=
+endif
+
+export PACKER_LOG
+
+# Fallback
+ifeq ($(strip $(ARCH)),amd64)
+ ARCH = x86_64
+endif
+
.PHONY: all clean
@@ -14,15 +29,30 @@ all: sles15.tar.gz
$(eval $(call check_packages_deps))
-sles15.tar.gz: check-deps clean
- ${PACKER} init sles.pkr.hcl && ${PACKER} build -var "sles15_iso_path=${ISO}" -var timeout=${TIMEOUT} -on-error=ask sles.pkr.hcl
-
-clean:
- ${RM} -rf output-sles15 sles15.tar.gz
-
lint:
packer validate .
packer fmt -check -diff .
format:
packer fmt .
+
+OVMF_VARS.fd: /usr/share/OVMF/OVMF_VARS${OVMF_SFX}.fd
+ cp -v $< ${ARCH}_VARS.fd
+
+SIZE_VARS.fd:
+ifeq ($(strip $(ARCH)),aarch64)
+ truncate -s 64m ${ARCH}_VARS.fd
+else
+ truncate -s 2m ${ARCH}_VARS.fd
+endif
+
+sles15.tar.gz: check-deps clean OVMF_VARS.fd SIZE_VARS.fd
+ ${PACKER} init sles.pkr.hcl && ${PACKER} build \
+ -var sles15_iso_path=${ISO} \
+ -var architecture=${ARCH} \
+ -var timeout=${TIMEOUT} \
+ -var ovmf_suffix=${OVMF_SFX} \
+ -var timeout=${TIMEOUT} -on-error=ask sles.pkr.hcl
+
+clean:
+ ${RM} -rf *.fd output-sles15 sles15.tar.gz
diff --git a/sles15/README.md b/sles15/README.md
index f4d6a5f..150b5e0 100644
--- a/sles15/README.md
+++ b/sles15/README.md
@@ -2,14 +2,14 @@
## Introduction
-The Packer template in this directory creates a SLES 15 AMD64 image for use with MAAS.
+The Packer template in this directory creates a SLES 15 AMD64/ARM64 image for use with MAAS.
## Prerequisites (to create the image)
* A machine running Ubuntu 22.04+ with the ability to run KVM virtual machines.
* qemu-utils, libnbd-bin, nbdkit and fuse2fs
* [Packer](https://www.packer.io/intro/getting-started/install.html), v1.8.0 or newer
-* The [SLES 15-SP4 DVD ISO](https://www.suse.com/download/sles/)
+* The [SLES 15 DVD ISO](https://www.suse.com/download/sles/)
## Requirements (to deploy the image)
@@ -18,27 +18,24 @@ The Packer template in this directory creates a SLES 15 AMD64 image for use with
## Customizing the Image
-The deployment image may be customized by modifying `http/sles15.xml`. See the [AutoYaST documentation](https://documentation.suse.com/sles/15-SP4/html/SLES-all/book-autoyast.html) for more information.
+The deployment image may be customized by modifying `http/sles15.xml.pkrtpl.hcl`. See the [AutoYaST documentation](https://documentation.suse.com/sles/15/html/SLES-all/book-autoyast.html) for more information.
## Building the image using a proxy
-The Packer template pulls all packages from the DVD ISO. To use a proxy during the installation you need to check the [AutoYaST documentation](https://documentation.suse.com/sles/15-SP4/html/SLES-all/book-autoyast.html).
+The Packer template pulls all packages from the DVD ISO. To use a proxy during the installation you need to check the [AutoYaST documentation](https://documentation.suse.com/sles/15/html/SLES-all/book-autoyast.html).
## Building an image
You can easily build the image using the Makefile:
```shell
-make ISO=/PATH/TO/SLE-15-SP4-Full-x86_64-GM-Media1.iso
+make ISO=/PATH/TO/SLE-15-SP6-Full-x86_64-GM-Media1.iso ARCH=x86_64
```
-Alternatively you can manually run packer. Your current working directory must
-be in `packer-maas/sles15`, where this file is located. Once in packer-maas/sles15
-you can generate an image with:
+To build arm64 images:
```shell
-packer init
-PACKER_LOG=1 packer build -var 'sles15_iso_path=/PATH/TO/SLE-15-SP4-Full-x86_64-GM-Media1.iso' .
+make ISO=/PATH/TO/SLE-15-SP6-Full-aarch64-GM-Media1.iso ARCH=aarch64
```
Note: `sles.pkr.hcl` is configured to run Packer in headless mode. Only Packer
@@ -50,6 +47,14 @@ Installation is non-interactive.
### Makefile Parameters
+#### ARCH
+
+Defaults to x86_64 to build AMD64 compatible images. In order to build ARM64 images, use ARCH=aarch64
+
+### ISO
+
+The path to the installation ISO image for SLES.
+
#### TIMEOUT
The timeout to apply when building the image. The default value is set to 1h.
@@ -58,7 +63,7 @@ The timeout to apply when building the image. The default value is set to 1h.
```shell
maas $PROFILE boot-resources create \
- name='suse/sles15.4' title='SLES 15-SP4' \
+ name='suse/sles15' title='SLES 15' \
architecture='amd64/generic' filetype='tgz' \
content@=sles15.tar.gz
```
diff --git a/sles15/http/sles15.xml b/sles15/http/sles15.xml.pkrtpl.hcl
similarity index 97%
rename from sles15/http/sles15.xml
rename to sles15/http/sles15.xml.pkrtpl.hcl
index 68e8449..8b36f31 100644
--- a/sles15/http/sles15.xml
+++ b/sles15/http/sles15.xml.pkrtpl.hcl
@@ -47,7 +47,7 @@
false
8
- grub2
+ grub2-efi
false
@@ -55,9 +55,11 @@
+ false
- true
+ true
false
+ false
@@ -180,8 +182,7 @@
tar
wget
xfsprogs
- grub2-i386-pc
- grub2-x86_64-efi
+ ${GRUB_PKGS}
grub2-branding-SLE
diff --git a/sles15/sles.pkr.hcl b/sles15/sles.pkr.hcl
index 15cd76f..35ddf9b 100644
--- a/sles15/sles.pkr.hcl
+++ b/sles15/sles.pkr.hcl
@@ -1,5 +1,5 @@
packer {
- required_version = ">= 1.7.0"
+ required_version = ">= 1.11.0"
required_plugins {
qemu = {
version = "~> 1.0"
@@ -25,18 +25,85 @@ variable "timeout" {
description = "Timeout for building the image"
}
+variable "architecture" {
+ type = string
+ default = "x86_64"
+ description = "The architecture to build the image for (x86_64 or aarch64)"
+}
+
+variable "ovmf_suffix" {
+ type = string
+ default = ""
+ description = "Suffix for OVMF CODE and VARS files. Newer systems such as Noble use _4M."
+}
+
+locals {
+ qemu_arch = {
+ "x86_64" = "x86_64"
+ "aarch64" = "aarch64"
+ }
+ uefi_imp = {
+ "x86_64" = "OVMF"
+ "aarch64" = "AAVMF"
+ }
+ uefi_sfx = {
+ "x86_64" = "${var.ovmf_suffix}"
+ "aarch64" = ""
+ }
+ qemu_machine = {
+ "x86_64" = "accel=kvm"
+ "aarch64" = "virt"
+ }
+ qemu_cpu = {
+ "x86_64" = "host"
+ "aarch64" = "max"
+ }
+ grub_pkgs = {
+ "x86_64" = "grub2-i386-pcgrub2-x86_64-efi"
+ "aarch64" = "grub2-arm64-efi"
+ }
+}
+
source "qemu" "sles15" {
- boot_command = ["", "linux netdevice=eth0 netsetup=dhcp install=cd:/", " lang=en_US autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/sles15.xml", " textmode=1", ""]
- boot_wait = "3s"
+ boot_command = ["", "e", "", "", "", "netdevice=eth0 vga=normal netsetup=dhcp install=cd:/ lang=en_US autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/sles15.xml textmode=1","x"]
+ boot_wait = "15s"
communicator = "none"
disk_size = "4G"
+ format = "qcow2"
headless = true
- http_directory = "http"
iso_checksum = "none"
iso_url = var.sles15_iso_path
+ cdrom_interface = "virtio-scsi"
memory = 4096
- qemuargs = [["-serial", "stdio"], ["-cpu", "host"]]
+ cores = 4
+ qemu_binary = "qemu-system-${lookup(local.qemu_arch, var.architecture, "")}"
+ qemuargs = [
+ ["-serial", "stdio"],
+ ["-boot", "strict=off"],
+ ["-device", "qemu-xhci"],
+ ["-device", "usb-kbd"],
+ ["-device", "virtio-net-pci,netdev=net0"],
+ ["-device", "virtio-scsi-pci"],
+ ["-netdev", "user,id=net0"],
+ ["-device", "virtio-blk-pci,drive=drive0,bootindex=0"],
+ ["-device", "scsi-cd,drive=cdrom0,bootindex=1"],
+ ["-machine", "${lookup(local.qemu_machine, var.architecture, "")}"],
+ ["-cpu", "${lookup(local.qemu_cpu, var.architecture, "")}"],
+ ["-device", "virtio-gpu-pci"],
+ ["-global", "driver=cfi.pflash01,property=secure,value=off"],
+ ["-drive", "if=pflash,format=raw,unit=0,id=ovmf_code,readonly=on,file=/usr/share/${lookup(local.uefi_imp, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_CODE${lookup(local.uefi_sfx, var.architecture, "")}.fd"],
+ ["-drive", "if=pflash,format=raw,unit=1,id=ovmf_vars,file=${var.architecture}_VARS.fd"],
+ ["-drive", "file=output-sles15/packer-sles15,if=none,id=drive0,cache=writeback,discard=ignore,format=qcow2"],
+ ["-drive", "file=${var.sles15_iso_path},if=none,id=cdrom0,media=cdrom"]
+ ]
shutdown_timeout = var.timeout
+ http_content = {
+ "/sles15.xml" = templatefile("${path.root}/http/sles15.xml.pkrtpl.hcl",
+ {
+ GRUB_PKGS = "${lookup(local.grub_pkgs, var.architecture, "")}"
+ }
+ )
+ }
}
build {