Skip to content

Commit

Permalink
Add raw image building support for rhel-9 and rhel-9 efi
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesh-goutham committed Mar 14, 2024
1 parent a41e9a3 commit d205629
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 2 deletions.
4 changes: 3 additions & 1 deletion images/capi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ QEMU_BUILD_NAMES ?= qemu-ubuntu-2004 qemu-ubuntu-2204 qemu-ubuntu-2304 qemu-ub

QEMU_KUBEVIRT_BUILD_NAMES := $(addprefix kubevirt-,$(QEMU_BUILD_NAMES))

RAW_BUILD_NAMES ?= raw-ubuntu-2004 raw-ubuntu-2004-efi raw-flatcar raw-rhel-8
RAW_BUILD_NAMES ?= raw-ubuntu-2004 raw-ubuntu-2004-efi raw-flatcar raw-rhel-8 raw-rhel-9 raw-rhel-9-efi
VBOX_BUILD_NAMES ?= vbox-windows-2019

POWERVS_BUILD_NAMES ?= powervs-centos-8
Expand Down Expand Up @@ -784,6 +784,8 @@ build-raw-flatcar: ## Builds Flatcar RAW image
build-raw-ubuntu-2004: ## Builds Ubuntu 20.04 RAW image
build-raw-ubuntu-2004-efi: ## Builds Ubuntu 20.04 RAW image that EFI boots
build-raw-rhel-8: ## Builds RHEL 8 RAW image
build-raw-rhel-9: ## Builds RHEL 9 RAW image
build-raw-rhel-9-efi: ## Builds RHEL 9 RAW image that EFI boots
build-raw-all: $(RAW_BUILD_TARGETS) ## Builds all RAW images

build-oci-ubuntu-2004: ## Builds the OCI ubuntu-2004 image
Expand Down
1 change: 0 additions & 1 deletion images/capi/packer/raw/linux/rhel

This file was deleted.

92 changes: 92 additions & 0 deletions images/capi/packer/raw/linux/rhel/7/ks.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Perform a fresh install, not an upgrade
install
cdrom

# Perform a text installation
text

# Do not install an X server
skipx

# Configure the locale/keyboard
lang en_US.UTF-8
keyboard us

# Configure networking
network --onboot yes --bootproto dhcp --hostname capv.vm
firewall --disabled
selinux --permissive
timezone UTC

# Don't flip out if unsupported hardware is detected
unsupported_hardware

# Configure the user(s)
auth --enableshadow --passalgo=sha512 --kickstart
user --name=builder --plaintext --password builder --groups=builder,wheel

# Disable general install minutia
firstboot --disabled
eula --agreed

# Create a single partition with no swap space
bootloader --location=mbr
zerombr
clearpart --all --initlabel
part / --grow --asprimary --fstype=ext4 --label=slash

%packages --ignoremissing --excludedocs
openssh-server
sed
sudo

# Remove unnecessary firmware
-*-firmware

# Remove other unnecessary packages
-postfix
%end

# Enable/disable the following services
services --enabled=sshd

# Perform a reboot once the installation has completed
reboot

# The %post section is essentially a shell script
%post --erroronfail

# Update the root certificates
update-ca-trust force-enable

# Ensure that the "builder" user doesn't require a password to use sudo,
# or else Ansible will fail
echo 'builder ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/builder
chmod 440 /etc/sudoers.d/builder

# Remove the package cache
yum -y clean all

# Disable swap
swapoff -a
rm -f /swapfile
sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab

# Ensure on next boot that network devices get assigned unique IDs.
sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-*

%end
74 changes: 74 additions & 0 deletions images/capi/packer/raw/linux/rhel/8/ks.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# version=RHEL8
# Install OS instead of upgrade
install
cdrom
auth --enableshadow --passalgo=sha512 --kickstart
# License agreement
eula --agreed
# Use text mode install
text
# Disable Initial Setup on first boot
firstboot --disable
# Keyboard layout
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=link --activate
network --hostname=rhel8
firewall --disabled
# Root password
rootpw builder --plaintext
# SELinux configuration
selinux --permissive
# Do not configure the X Window System
skipx
# System timezone
timezone UTC
# Add a user named builder
user --groups=wheel --name=builder --password=builder --plaintext --gecos="builder"

# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
clearpart --all --initlabel --drives=sda
part / --fstype="ext4" --grow --asprimary --label=slash --ondisk=sda

# Reboot after successful installation
reboot

%packages --ignoremissing --excludedocs
# dnf group info minimal-environment
@^minimal-environment
@core
openssh-server
sed
sudo
python3

# Exclude unnecessary firmwares
-iwl*firmware
%end

# Enable/disable the following services
services --enabled=sshd

%post --nochroot --logfile=/mnt/sysimage/root/ks-post.log
# Disable quiet boot and splash screen
sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/etc/default/grub
sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/boot/grub2/grubenv

# Passwordless sudo for the user 'builder'
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /mnt/sysimage/etc/sudoers.d/builder
# Remove the package cache
yum -y clean all

# Disable swap
swapoff -a
rm -f /swapfile
sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab

sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-*

%end
76 changes: 76 additions & 0 deletions images/capi/packer/raw/linux/rhel/9/ks-efi.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# version=RHEL9
# Install OS instead of upgrade
cdrom
authselect --enableshadow --passalgo=sha512 --kickstart
# License agreement
eula --agreed
# Use text mode install
text
# Disable Initial Setup on first boot
firstboot --disable
# Keyboard layout
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=link --activate
network --hostname=centos9
firewall --disabled
# Root password
rootpw builder --plaintext
# SELinux configuration
selinux --permissive
# Do not configure the X Window System
skipx
# System timezone
timezone UTC
# Add a user named builder
user --groups=wheel --name=builder --password=builder --plaintext --gecos="builder"

# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
clearpart --all --initlabel --drives=sda
part / --fstype="ext4" --grow --asprimary --label=slash --ondisk=sda
part /boot/efi --fstype="efi" --ondisk=sda --size=200 --fsoptions="umask=0077,shortname=winnt"
part swap --fstype="swap" --ondisk=sda --size=100
part /boot --fstype="ext4" --ondisk=sda --size=1024

# Reboot after successful installation
reboot

%packages --ignoremissing --excludedocs
# dnf group info minimal-environment
@^minimal-environment
@core
openssh-server
sed
sudo
python3

# Exclude unnecessary firmwares
-iwl*firmware
%end

# Enable/disable the following services
services --enabled=sshd

%post --nochroot --logfile=/mnt/sysimage/root/ks-post.log
# Disable quiet boot and splash screen
sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/etc/default/grub
sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/boot/grub2/grubenv

# Passwordless sudo for the user 'builder'
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /mnt/sysimage/etc/sudoers.d/builder
# Remove the package cache
yum -y clean all

# Disable swap
swapoff -a
rm -f /swapfile
sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab

sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-*

%end
73 changes: 73 additions & 0 deletions images/capi/packer/raw/linux/rhel/9/ks.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# version=RHEL9
# Install OS instead of upgrade
cdrom
authselect --enableshadow --passalgo=sha512 --kickstart
# License agreement
eula --agreed
# Use text mode install
text
# Disable Initial Setup on first boot
firstboot --disable
# Keyboard layout
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=link --activate
network --hostname=centos9
firewall --disabled
# Root password
rootpw builder --plaintext
# SELinux configuration
selinux --permissive
# Do not configure the X Window System
skipx
# System timezone
timezone UTC
# Add a user named builder
user --groups=wheel --name=builder --password=builder --plaintext --gecos="builder"

# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
clearpart --all --initlabel --drives=sda
part / --fstype="ext4" --grow --asprimary --label=slash --ondisk=sda

# Reboot after successful installation
reboot

%packages --ignoremissing --excludedocs
# dnf group info minimal-environment
@^minimal-environment
@core
openssh-server
sed
sudo
python3

# Exclude unnecessary firmwares
-iwl*firmware
%end

# Enable/disable the following services
services --enabled=sshd

%post --nochroot --logfile=/mnt/sysimage/root/ks-post.log
# Disable quiet boot and splash screen
sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/etc/default/grub
sed --follow-symlinks -i "s/ rhgb quiet//" /mnt/sysimage/boot/grub2/grubenv

# Passwordless sudo for the user 'builder'
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /mnt/sysimage/etc/sudoers.d/builder
# Remove the package cache
yum -y clean all

# Disable swap
swapoff -a
rm -f /swapfile
sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab

sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-*

%end
1 change: 1 addition & 0 deletions images/capi/packer/raw/packer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"{{user `boot_command_suffix`}}"
],
"boot_wait": "{{user `boot_wait`}}",
"cpu_model": "{{user `cpu_model`}}",
"cpus": "{{user `cpus`}}",
"disk_compression": "{{ user `disk_compression`}}",
"disk_discard": "{{user `disk_discard`}}",
Expand Down
19 changes: 19 additions & 0 deletions images/capi/packer/raw/raw-rhel-9-efi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"boot_command_prefix": "<up>e <down><down><end><wait> text inst.ks=",
"boot_command_suffix": "/9/ks-efi.cfg<enter><wait><leftCtrlOn>x<leftCtrlOff>",
"build_name": "rhel-9",
"build_target": "raw",
"cpu_model": "host",
"distribution_version": "9",
"distro_name": "rhel",
"distro_version": "9",
"epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-9",
"firmware": "OVMF.fd",
"guest_os_type": "RedHat_64",
"iso_checksum": "5c802147aa58429b21e223ee60e347e850d6b0d8680930c4ffb27340ffb687a8",
"iso_checksum_type": "sha256",
"iso_url": "rhel-9.3-x86_64-dvd.iso",
"os_display_name": "RHEL 9",
"redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm",
"shutdown_command": "shutdown -P now"
}
18 changes: 18 additions & 0 deletions images/capi/packer/raw/raw-rhel-9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"boot_command_prefix": "<tab> text inst.ks=",
"boot_command_suffix": "/9/ks.cfg<enter><wait>",
"build_name": "rhel-9",
"build_target": "raw",
"cpu_model": "host",
"distribution_version": "9",
"distro_name": "rhel",
"distro_version": "9",
"epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-9",
"guest_os_type": "RedHat_64",
"iso_checksum": "5c802147aa58429b21e223ee60e347e850d6b0d8680930c4ffb27340ffb687a8",
"iso_checksum_type": "sha256",
"iso_url": "rhel-9.3-x86_64-dvd.iso",
"os_display_name": "RHEL 9",
"redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm",
"shutdown_command": "shutdown -P now"
}

0 comments on commit d205629

Please sign in to comment.