-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for CentOS 9 Stream (#173)
New pull request to add support for CentOS 9 Stream.
- Loading branch information
Showing
5 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/make -f | ||
|
||
include ../scripts/check.mk | ||
|
||
PACKER ?= packer | ||
PACKER_LOG ?= 0 | ||
|
||
export PACKER_LOG KS_PROXY | ||
|
||
.PHONY: all clean | ||
|
||
all: centos9-stream.tar.gz | ||
|
||
$(eval $(call check_packages_deps)) | ||
|
||
centos9-stream.tar.gz: check-deps clean http/centos9-stream.ks | ||
${PACKER} init centos9-stream.pkr.hcl && ${PACKER} build centos9-stream.pkr.hcl | ||
|
||
http/centos9-stream.ks: http/centos9-stream.ks.in | ||
envsubst '$${KS_PROXY}' < $< | tee $@ | ||
|
||
clean: | ||
${RM} -rf output-centos9-stream centos9-stream.tar.gz http/centos9-stream.ks | ||
|
||
.INTERMEDIATE: http/centos9-stream.ks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# CentOS 9 Stream Packer Template for MAAS | ||
|
||
## Introduction | ||
|
||
The Packer template in this directory creates a CentOS 9 Stream 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.7.0 or newer | ||
|
||
## Requirements (to deploy the image) | ||
|
||
* [MAAS](https://maas.io) 3.0, [MAAS](https://maas.io) 3.2 recommended | ||
* [Curtin](https://launchpad.net/curtin) 21+ | ||
|
||
## Default user | ||
|
||
The default username is cloud-user | ||
|
||
## Customizing the Image | ||
|
||
The deployment image may be customized by modifying http/centos9-stream.ks. See the [CentOS kickstart documentation](https://docs.centos.org/en-US/centos/install-guide/Kickstart2/) for more information. | ||
|
||
## Building the image using a proxy | ||
|
||
The Packer template downloads the CentOS 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. | ||
|
||
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/centos9-stream, where this file is located. Once in | ||
packer-maas/centos9-stream you can generate an image with: | ||
|
||
```shell | ||
packer init | ||
PACKER_LOG=1 packer build . | ||
``` | ||
|
||
Note: centos9-stream.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 | ||
centos9-stream.pkr.hcl. | ||
|
||
Installation is non-interactive. | ||
|
||
## Uploading an image to MAAS | ||
|
||
```shell | ||
maas $PROFILE boot-resources create \ | ||
name='custom/9-stream-custom' title='CentOS 9 Stream Custom' \ | ||
architecture='amd64/generic' filetype='tgz' base_image='rhel/9' \ | ||
content@=centos9-stream.tar.gz | ||
``` | ||
|
||
## Default Username | ||
|
||
The default username is ```cloud-user``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
packer { | ||
required_version = ">= 1.7.0" | ||
required_plugins { | ||
qemu = { | ||
version = "~> 1.0" | ||
source = "github.com/hashicorp/qemu" | ||
} | ||
} | ||
} | ||
|
||
variable "filename" { | ||
type = string | ||
default = "centos9-stream.tar.gz" | ||
description = "The filename of the tarball to produce" | ||
} | ||
|
||
variable "centos9_stream_iso_url" { | ||
type = string | ||
default = "https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso" | ||
} | ||
|
||
source "qemu" "centos9-stream" { | ||
boot_command = ["<up><tab> ", "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos9-stream.ks ", "console=ttyS0 inst.cmdline", "<enter>"] | ||
boot_wait = "3s" | ||
communicator = "none" | ||
disk_size = "4G" | ||
headless = true | ||
http_directory = "http" | ||
iso_checksum = "none" | ||
iso_url = var.centos9_stream_iso_url | ||
memory = 2048 | ||
qemuargs = [["-serial", "stdio"], ["-cpu", "host"]] | ||
shutdown_timeout = "1h" | ||
} | ||
|
||
build { | ||
sources = ["source.qemu.centos9-stream"] | ||
|
||
post-processor "shell-local" { | ||
inline = [ | ||
"SOURCE=centos9-stream", | ||
"OUTPUT=${var.filename}", | ||
"source ../scripts/fuse-nbd", | ||
"source ../scripts/fuse-tar-root" | ||
] | ||
inline_shebang = "/bin/bash -e" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
url --mirrorlist=https://mirrors.centos.org/metalink?repo=centos-baseos-9-stream&arch=x86_64&protocol=https,http ${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 --isUtc | ||
bootloader --location=mbr --driveorder="vda" --timeout=1 | ||
rootpw --plaintext password | ||
|
||
repo --name=baseos --metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-9-stream&arch=x86_64&protocol=https,http ${KS_PROXY} | ||
repo --name=appstream --metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-9-stream&arch=x86_64&protocol=https,http ${KS_PROXY} | ||
repo --name=centos --metalink=https://mirrors.centos.org/metalink?repo=centos-crb-9-stream&arch=x86_64&protocol=https,http ${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 |