From dad081b9729a3af9a7f3531ab0beae424cce057f Mon Sep 17 00:00:00 2001 From: Stamatis Katsaounis Date: Tue, 10 Oct 2023 13:13:34 +0300 Subject: [PATCH] Add support for OL9 --- README.md | 2 ++ ol8/Makefile | 26 +++++++++++++++++ ol8/README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++ ol8/http/ol8.ks.in | 70 +++++++++++++++++++++++++++++++++++++++++++++ ol8/ol8.pkr.hcl | 53 ++++++++++++++++++++++++++++++++++ ol9/Makefile | 26 +++++++++++++++++ ol9/README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++ ol9/http/ol9.ks.in | 70 +++++++++++++++++++++++++++++++++++++++++++++ ol9/ol9.pkr.hcl | 53 ++++++++++++++++++++++++++++++++++ 9 files changed, 442 insertions(+) create mode 100644 ol8/Makefile create mode 100644 ol8/README.md create mode 100644 ol8/http/ol8.ks.in create mode 100644 ol8/ol8.pkr.hcl create mode 100644 ol9/Makefile create mode 100644 ol9/README.md create mode 100644 ol9/http/ol9.ks.in create mode 100644 ol9/ol9.pkr.hcl diff --git a/README.md b/README.md index af7c8e81..38478ea0 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Read more about how [custom images](https://maas.io/docs/how-to-customise-images | CentOS 7 | Stable | | CentOS 8 | EOL | | CentOS 8 Stream | Beta | +| OL8 | Beta | +| OL9 | Beta | | RHEL 7 | EOL | | RHEL 8 | Stable | | RHEL 9 | Beta | diff --git a/ol8/Makefile b/ol8/Makefile new file mode 100644 index 00000000..9961a2a5 --- /dev/null +++ b/ol8/Makefile @@ -0,0 +1,26 @@ +#!/usr/bin/make -f + +include ../scripts/check.mk + +PACKER ?= packer +PACKER_LOG ?= 0 + +export PACKER_LOG KS_PROXY + +.PHONY: all clean + +all: ol8.tar.gz + +check-deps: + $(call check_packages_deps) + +ol8.tar.gz: check-deps clean http/ol8.ks + ${PACKER} init ol8.pkr.hcl && ${PACKER} build ol8.pkr.hcl + +http/ol8.ks: http/ol8.ks.in + envsubst '$${KS_PROXY}' < $< | tee $@ + +clean: + ${RM} -rf output-ol8 ol8.tar.gz http/ol8.ks + +.INTERMEDIATE: http/ol8.ks diff --git a/ol8/README.md b/ol8/README.md new file mode 100644 index 00000000..4b307ff7 --- /dev/null +++ b/ol8/README.md @@ -0,0 +1,71 @@ +# OL 8 Packer Template for MAAS + +## Introduction + +The Packer template in this directory creates an OL 8 AMD64 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 + +## Requirements (to deploy the image) + +* [MAAS](https://maas.io) ___stamatis_version_replace_me___ +* [Curtin](https://launchpad.net/curtin) ___stamatis_version_replace_me___ + +## Customizing the Image + +The deployment image may be customized by modifying http/ol8.ks. See the [OL8 kickstart documentation](https://docs.oracle.com/en/operating-systems/oracle-linux/8/install/install-AutomatinganOracleLinuxInstallationbyUsingKickstart.html) for more information. + +## Building the image using a proxy + +The Packer template downloads the OL net installer from the Internet. To +tell Packer to use a proxy set the HTTP_PROXY environment variable to your proxy +server. Alternatively you may redefine iso_url to a local file, set +iso_checksum_type to none to disable checksuming, and remove iso_checksum_url. + +To use a proxy during the installation define the `KS_PROXY` variable in the +environment, as bellow: + +```shell +export KS_PROXY="--proxy=\"${HTTP_PROXY}\"" +``` + +## Building an image + +You can easily build the image using the Makefile: + +```shell +make +``` + +Alternatively you can manually run packer. Your current working directory must +be in packer-maas/ol8, where this file is located. Once in packer-maas/ol8 +you can generate an image with: + +```shell +packer init +PACKER_LOG=1 packer build . +``` + +Note: ol8.pkr.hcl is configured to run Packer in headless mode. Only Packer +output will be seen. If you wish to see the installation output connect to the +VNC port given in the Packer output or change the value of headless to false in +ol8.pkr.hcl. + +Installation is non-interactive. + +## Uploading an image to MAAS + +```shell +maas $PROFILE boot-resources create \ + name='ol/8.8' title='Oracle Linux 8.8' \ + architecture='amd64/generic' filetype='tgz' \ + content@=ol8.tar.gz +``` + +## Default Username + +The default username is ```cloud-user``` diff --git a/ol8/http/ol8.ks.in b/ol8/http/ol8.ks.in new file mode 100644 index 00000000..f6491d7b --- /dev/null +++ b/ol8/http/ol8.ks.in @@ -0,0 +1,70 @@ +url --url="https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64" ${KS_PROXY} +poweroff +firewall --enabled --service=ssh +firstboot --disable +ignoredisk --only-use=vda +lang en_US.UTF-8 +keyboard us +network --device eth0 --bootproto=dhcp +firewall --enabled --service=ssh +selinux --enforcing +timezone UTC --utc +bootloader --location=mbr --driveorder="vda" --timeout=1 +rootpw --plaintext password + +repo --name="ol8_AppStream" --baseurl="https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/" ${KS_PROXY} + +zerombr +clearpart --all --initlabel +part / --size=1 --grow --asprimary --fstype=ext4 + +%post --erroronfail +# workaround anaconda requirements and clear root password +passwd -d root +passwd -l root + +# Clean up install config not applicable to deployed environments. +for f in resolv.conf fstab; do + rm -f /etc/$f + touch /etc/$f + chown root:root /etc/$f + chmod 644 /etc/$f +done + +rm -f /etc/sysconfig/network-scripts/ifcfg-[^lo]* + +# Kickstart copies install boot options. Serial is turned on for logging with +# Packer which disables console output. Disable it so console output is shown +# during deployments +sed -i 's/^GRUB_TERMINAL=.*/GRUB_TERMINAL_OUTPUT="console"/g' /etc/default/grub +sed -i '/GRUB_SERIAL_COMMAND="serial"/d' /etc/default/grub +sed -ri 's/(GRUB_CMDLINE_LINUX=".*)\s+console=ttyS0(.*")/\1\2/' /etc/default/grub +sed -i 's/"GRUB_ENABLE_BLSCFG=.*"/"GRUB_ENABLE_BLSCFG=false"/g' /etc/default/grub + +dnf clean all +%end + +%packages +@core +bash-completion +cloud-init +# cloud-init only requires python3-oauthlib with MAAS. As such upstream +# removed this dependency. +python3-oauthlib +rsync +tar +# grub2-efi-x64 ships grub signed for UEFI secure boot. If grub2-efi-x64-modules +# is installed grub will be generated on deployment and unsigned which breaks +# UEFI secure boot. +grub2-efi-x64 +efibootmgr +shim-x64 +dosfstools +lvm2 +mdadm +device-mapper-multipath +iscsi-initiator-utils +-plymouth +# Remove Intel wireless firmware +-i*-firmware +%end diff --git a/ol8/ol8.pkr.hcl b/ol8/ol8.pkr.hcl new file mode 100644 index 00000000..7ac05ae4 --- /dev/null +++ b/ol8/ol8.pkr.hcl @@ -0,0 +1,53 @@ +packer { + required_version = ">= 1.7.0" + required_plugins { + qemu = { + version = "~> 1.0" + source = "github.com/hashicorp/qemu" + } + } +} + +variable "filename" { + type = string + default = "ol8.tar.gz" + description = "The filename of the tarball to produce" +} + +variable "ol8_iso_url" { + type = string + default = "https://yum.oracle.com/ISOS/OracleLinux/OL8/u8/x86_64/x86_64-boot.iso" +} + +variable "ol8_sha256sum_path" { + type = string + default = "https://linux.oracle.com/security/gpg/checksum/OracleLinux-R8-U8-Server-x86_64.checksum" +} + +source "qemu" "ol8" { + boot_command = [" ", "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ol8.ks ", "console=ttyS0 inst.cmdline", ""] + boot_wait = "3s" + communicator = "none" + disk_size = "4G" + headless = true + http_directory = "http" + iso_checksum = "file:${var.ol8_sha256sum_path}" + iso_url = var.ol8_iso_url + memory = 2048 + qemuargs = [["-serial", "stdio"], ["-cpu", "host"]] + shutdown_timeout = "1h" +} + +build { + sources = ["source.qemu.ol8"] + + post-processor "shell-local" { + inline = [ + "SOURCE=ol8", + "OUTPUT=${var.filename}", + "source ../scripts/fuse-nbd", + "source ../scripts/fuse-tar-root" + ] + inline_shebang = "/bin/bash -e" + } +} diff --git a/ol9/Makefile b/ol9/Makefile new file mode 100644 index 00000000..de0371b1 --- /dev/null +++ b/ol9/Makefile @@ -0,0 +1,26 @@ +#!/usr/bin/make -f + +include ../scripts/check.mk + +PACKER ?= packer +PACKER_LOG ?= 0 + +export PACKER_LOG KS_PROXY + +.PHONY: all clean + +all: ol9.tar.gz + +check-deps: + $(call check_packages_deps) + +ol9.tar.gz: check-deps clean http/ol9.ks + ${PACKER} init ol9.pkr.hcl && ${PACKER} build ol9.pkr.hcl + +http/ol9.ks: http/ol9.ks.in + envsubst '$${KS_PROXY}' < $< | tee $@ + +clean: + ${RM} -rf output-ol9 ol9.tar.gz http/ol9.ks + +.INTERMEDIATE: http/ol9.ks diff --git a/ol9/README.md b/ol9/README.md new file mode 100644 index 00000000..15511c3b --- /dev/null +++ b/ol9/README.md @@ -0,0 +1,71 @@ +# OL 9 Packer Template for MAAS + +## Introduction + +The Packer template in this directory creates an OL 9 AMD64 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 + +## Requirements (to deploy the image) + +* [MAAS](https://maas.io) ___stamatis_version_replace_me___ +* [Curtin](https://launchpad.net/curtin) ___stamatis_version_replace_me___ + +## Customizing the Image + +The deployment image may be customized by modifying http/ol9.ks. See the [OL9 kickstart documentation](https://docs.oracle.com/en/operating-systems/oracle-linux/9/install/install-AutomatinganOracleLinuxInstallationbyUsingKickstart.html) for more information. + +## Building the image using a proxy + +The Packer template downloads the OL net installer from the Internet. To +tell Packer to use a proxy set the HTTP_PROXY environment variable to your proxy +server. Alternatively you may redefine iso_url to a local file, set +iso_checksum_type to none to disable checksuming, and remove iso_checksum_url. + +To use a proxy during the installation define the `KS_PROXY` variable in the +environment, as bellow: + +```shell +export KS_PROXY="--proxy=\"${HTTP_PROXY}\"" +``` + +## Building an image + +You can easily build the image using the Makefile: + +```shell +make +``` + +Alternatively you can manually run packer. Your current working directory must +be in packer-maas/ol9, where this file is located. Once in packer-maas/ol9 +you can generate an image with: + +```shell +packer init +PACKER_LOG=1 packer build . +``` + +Note: ol9.pkr.hcl is configured to run Packer in headless mode. Only Packer +output will be seen. If you wish to see the installation output connect to the +VNC port given in the Packer output or change the value of headless to false in +ol9.pkr.hcl. + +Installation is non-interactive. + +## Uploading an image to MAAS + +```shell +maas $PROFILE boot-resources create \ + name='ol/9.2' title='Oracle Linux 9.2' \ + architecture='amd64/generic' filetype='tgz' \ + content@=ol9.tar.gz +``` + +## Default Username + +The default username is ```cloud-user``` diff --git a/ol9/http/ol9.ks.in b/ol9/http/ol9.ks.in new file mode 100644 index 00000000..08d68b8e --- /dev/null +++ b/ol9/http/ol9.ks.in @@ -0,0 +1,70 @@ +url --url="https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/x86_64" ${KS_PROXY} +poweroff +firewall --enabled --service=ssh +firstboot --disable +ignoredisk --only-use=vda +lang en_US.UTF-8 +keyboard us +network --device eth0 --bootproto=dhcp +firewall --enabled --service=ssh +selinux --enforcing +timezone UTC --utc +bootloader --location=mbr --driveorder="vda" --timeout=1 +rootpw --plaintext password + +repo --name="ol9_AppStream" --baseurl="https://yum.oracle.com/repo/OracleLinux/OL9/appstream/x86_64/" ${KS_PROXY} + +zerombr +clearpart --all --initlabel +part / --size=1 --grow --asprimary --fstype=ext4 + +%post --erroronfail +# workaround anaconda requirements and clear root password +passwd -d root +passwd -l root + +# Clean up install config not applicable to deployed environments. +for f in resolv.conf fstab; do + rm -f /etc/$f + touch /etc/$f + chown root:root /etc/$f + chmod 644 /etc/$f +done + +rm -f /etc/sysconfig/network-scripts/ifcfg-[^lo]* + +# Kickstart copies install boot options. Serial is turned on for logging with +# Packer which disables console output. Disable it so console output is shown +# during deployments +sed -i 's/^GRUB_TERMINAL=.*/GRUB_TERMINAL_OUTPUT="console"/g' /etc/default/grub +sed -i '/GRUB_SERIAL_COMMAND="serial"/d' /etc/default/grub +sed -ri 's/(GRUB_CMDLINE_LINUX=".*)\s+console=ttyS0(.*")/\1\2/' /etc/default/grub +sed -i 's/"GRUB_ENABLE_BLSCFG=.*"/"GRUB_ENABLE_BLSCFG=false"/g' /etc/default/grub + +dnf clean all +%end + +%packages +@core +bash-completion +cloud-init +# cloud-init only requires python3-oauthlib with MAAS. As such upstream +# removed this dependency. +python3-oauthlib +rsync +tar +# grub2-efi-x64 ships grub signed for UEFI secure boot. If grub2-efi-x64-modules +# is installed grub will be generated on deployment and unsigned which breaks +# UEFI secure boot. +grub2-efi-x64 +efibootmgr +shim-x64 +dosfstools +lvm2 +mdadm +device-mapper-multipath +iscsi-initiator-utils +-plymouth +# Remove Intel wireless firmware +-i*-firmware +%end diff --git a/ol9/ol9.pkr.hcl b/ol9/ol9.pkr.hcl new file mode 100644 index 00000000..9e0d1717 --- /dev/null +++ b/ol9/ol9.pkr.hcl @@ -0,0 +1,53 @@ +packer { + required_version = ">= 1.7.0" + required_plugins { + qemu = { + version = "~> 1.0" + source = "github.com/hashicorp/qemu" + } + } +} + +variable "filename" { + type = string + default = "ol9.tar.gz" + description = "The filename of the tarball to produce" +} + +variable "ol9_iso_url" { + type = string + default = "https://yum.oracle.com/ISOS/OracleLinux/OL9/u2/x86_64/OracleLinux-R9-U2-x86_64-boot.iso" +} + +variable "ol9_sha256sum_path" { + type = string + default = "https://linux.oracle.com/security/gpg/checksum/OracleLinux-R9-U2-Server-x86_64.checksum" +} + +source "qemu" "ol9" { + boot_command = [" ", "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ol9.ks ", "console=ttyS0 inst.cmdline", ""] + boot_wait = "3s" + communicator = "none" + disk_size = "4G" + headless = true + http_directory = "http" + iso_checksum = "file:${var.ol9_sha256sum_path}" + iso_url = var.ol9_iso_url + memory = 2048 + qemuargs = [["-serial", "stdio"], ["-cpu", "host"]] + shutdown_timeout = "1h" +} + +build { + sources = ["source.qemu.ol9"] + + post-processor "shell-local" { + inline = [ + "SOURCE=ol9", + "OUTPUT=${var.filename}", + "source ../scripts/fuse-nbd", + "source ../scripts/fuse-tar-root" + ] + inline_shebang = "/bin/bash -e" + } +}