From ea0480efae75b4e94514d36fc537cb34a1e3a744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 12:49:24 +0100 Subject: [PATCH 01/12] RHEL-10/Azure: merge the CS and RHEL image generator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge the image generator functions used for the Azure images. One was used for the CentOS Stream and the other for RHEL images. However, the underlying image was exactly the same (WRT image config, partitioning, etc.). This change has no effect on the resulting manifests. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/azure.go | 283 ++++++++++++++----------------- pkg/distro/rhel/rhel10/distro.go | 9 +- 2 files changed, 133 insertions(+), 159 deletions(-) diff --git a/pkg/distro/rhel/rhel10/azure.go b/pkg/distro/rhel/rhel10/azure.go index 610b1c5c22..be58220193 100644 --- a/pkg/distro/rhel/rhel10/azure.go +++ b/pkg/distro/rhel/rhel10/azure.go @@ -9,8 +9,8 @@ import ( "github.com/osbuild/images/pkg/rpmmd" ) -// Azure non-RHEL image type -func mkAzureImgType() *rhel.ImageType { +// Azure image type +func mkAzureImgType(rd *rhel.Distribution) *rhel.ImageType { it := rhel.NewImageType( "vhd", "disk.vhd", @@ -27,31 +27,7 @@ func mkAzureImgType() *rhel.ImageType { it.KernelOptions = defaultAzureKernelOptions it.Bootable = true it.DefaultSize = 4 * datasizes.GibiByte - it.DefaultImageConfig = defaultAzureImageConfig - it.BasePartitionTables = defaultBasePartitionTables - - return it -} - -// Azure BYOS image type -func mkAzureByosImgType(rd distro.Distro) *rhel.ImageType { - it := rhel.NewImageType( - "vhd", - "disk.vhd", - "application/x-vhd", - map[string]rhel.PackageSetFunc{ - rhel.OSPkgsKey: azurePackageSet, - }, - rhel.DiskImage, - []string{"build"}, - []string{"os", "image", "vpc"}, - []string{"vpc"}, - ) - - it.KernelOptions = defaultAzureKernelOptions - it.Bootable = true - it.DefaultSize = 4 * datasizes.GibiByte - it.DefaultImageConfig = defaultAzureImageConfig + it.DefaultImageConfig = defaultAzureImageConfig(rd) it.BasePartitionTables = defaultBasePartitionTables return it @@ -149,155 +125,158 @@ func azurePackageSet(t *rhel.ImageType) rpmmd.PackageSet { const defaultAzureKernelOptions = "ro loglevel=3 console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300" // based on https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/deploying_rhel_9_on_microsoft_azure/assembly_deploying-a-rhel-image-as-a-virtual-machine-on-microsoft-azure_cloud-content-azure#making-configuration-changes_configure-the-image-azure -var defaultAzureImageConfig = &distro.ImageConfig{ - Timezone: common.ToPtr("Etc/UTC"), - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - X11Keymap: &osbuild.X11KeymapOptions{ - Layouts: []string{"us"}, - }, - }, - Sysconfig: []*osbuild.SysconfigStageOptions{ - { - Kernel: &osbuild.SysconfigKernelOptions{ - UpdateDefault: true, - DefaultKernel: "kernel-core", +func defaultAzureImageConfig(rd *rhel.Distribution) *distro.ImageConfig { + ic := &distro.ImageConfig{ + Timezone: common.ToPtr("Etc/UTC"), + Locale: common.ToPtr("en_US.UTF-8"), + Keyboard: &osbuild.KeymapStageOptions{ + Keymap: "us", + X11Keymap: &osbuild.X11KeymapOptions{ + Layouts: []string{"us"}, }, - Network: &osbuild.SysconfigNetworkOptions{ - Networking: true, - NoZeroConf: true, + }, + Sysconfig: []*osbuild.SysconfigStageOptions{ + { + Kernel: &osbuild.SysconfigKernelOptions{ + UpdateDefault: true, + DefaultKernel: "kernel-core", + }, + Network: &osbuild.SysconfigNetworkOptions{ + Networking: true, + NoZeroConf: true, + }, }, }, - }, - EnabledServices: []string{ - "firewalld", - "nm-cloud-setup.service", - "nm-cloud-setup.timer", - "sshd", - "waagent", - }, - SshdConfig: &osbuild.SshdConfigStageOptions{ - Config: osbuild.SshdConfigConfig{ - ClientAliveInterval: common.ToPtr(180), + EnabledServices: []string{ + "firewalld", + "nm-cloud-setup.service", + "nm-cloud-setup.timer", + "sshd", + "waagent", }, - }, - Modprobe: []*osbuild.ModprobeStageOptions{ - { - Filename: "blacklist-amdgpu.conf", - Commands: osbuild.ModprobeConfigCmdList{ - osbuild.NewModprobeConfigCmdBlacklist("amdgpu"), + SshdConfig: &osbuild.SshdConfigStageOptions{ + Config: osbuild.SshdConfigConfig{ + ClientAliveInterval: common.ToPtr(180), }, }, - { - Filename: "blacklist-intel-cstate.conf", - Commands: osbuild.ModprobeConfigCmdList{ - osbuild.NewModprobeConfigCmdBlacklist("intel_cstate"), + Modprobe: []*osbuild.ModprobeStageOptions{ + { + Filename: "blacklist-amdgpu.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("amdgpu"), + }, }, - }, - { - Filename: "blacklist-floppy.conf", - Commands: osbuild.ModprobeConfigCmdList{ - osbuild.NewModprobeConfigCmdBlacklist("floppy"), + { + Filename: "blacklist-intel-cstate.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("intel_cstate"), + }, }, - }, - { - Filename: "blacklist-nouveau.conf", - Commands: osbuild.ModprobeConfigCmdList{ - osbuild.NewModprobeConfigCmdBlacklist("nouveau"), - osbuild.NewModprobeConfigCmdBlacklist("lbm-nouveau"), + { + Filename: "blacklist-floppy.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("floppy"), + }, }, - }, - { - Filename: "blacklist-skylake-edac.conf", - Commands: osbuild.ModprobeConfigCmdList{ - osbuild.NewModprobeConfigCmdBlacklist("skx_edac"), + { + Filename: "blacklist-nouveau.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("nouveau"), + osbuild.NewModprobeConfigCmdBlacklist("lbm-nouveau"), + }, }, - }, - }, - CloudInit: []*osbuild.CloudInitStageOptions{ - { - Filename: "10-azure-kvp.cfg", - Config: osbuild.CloudInitConfigFile{ - Reporting: &osbuild.CloudInitConfigReporting{ - Logging: &osbuild.CloudInitConfigReportingHandlers{ - Type: "log", - }, - Telemetry: &osbuild.CloudInitConfigReportingHandlers{ - Type: "hyperv", - }, + { + Filename: "blacklist-skylake-edac.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("skx_edac"), }, }, }, - { - Filename: "91-azure_datasource.cfg", - Config: osbuild.CloudInitConfigFile{ - Datasource: &osbuild.CloudInitConfigDatasource{ - Azure: &osbuild.CloudInitConfigDatasourceAzure{ - ApplyNetworkConfig: false, + CloudInit: []*osbuild.CloudInitStageOptions{ + { + Filename: "10-azure-kvp.cfg", + Config: osbuild.CloudInitConfigFile{ + Reporting: &osbuild.CloudInitConfigReporting{ + Logging: &osbuild.CloudInitConfigReportingHandlers{ + Type: "log", + }, + Telemetry: &osbuild.CloudInitConfigReportingHandlers{ + Type: "hyperv", + }, }, }, - DatasourceList: []string{ - "Azure", + }, + { + Filename: "91-azure_datasource.cfg", + Config: osbuild.CloudInitConfigFile{ + Datasource: &osbuild.CloudInitConfigDatasource{ + Azure: &osbuild.CloudInitConfigDatasourceAzure{ + ApplyNetworkConfig: false, + }, + }, + DatasourceList: []string{ + "Azure", + }, }, }, }, - }, - PwQuality: &osbuild.PwqualityConfStageOptions{ - Config: osbuild.PwqualityConfConfig{ - Minlen: common.ToPtr(6), - Minclass: common.ToPtr(3), - Dcredit: common.ToPtr(0), - Ucredit: common.ToPtr(0), - Lcredit: common.ToPtr(0), - Ocredit: common.ToPtr(0), + PwQuality: &osbuild.PwqualityConfStageOptions{ + Config: osbuild.PwqualityConfConfig{ + Minlen: common.ToPtr(6), + Minclass: common.ToPtr(3), + Dcredit: common.ToPtr(0), + Ucredit: common.ToPtr(0), + Lcredit: common.ToPtr(0), + Ocredit: common.ToPtr(0), + }, }, - }, - WAAgentConfig: &osbuild.WAAgentConfStageOptions{ - Config: osbuild.WAAgentConfig{ - RDFormat: common.ToPtr(false), - RDEnableSwap: common.ToPtr(false), + WAAgentConfig: &osbuild.WAAgentConfStageOptions{ + Config: osbuild.WAAgentConfig{ + RDFormat: common.ToPtr(false), + RDEnableSwap: common.ToPtr(false), + }, }, - }, - Grub2Config: &osbuild.GRUB2Config{ - DisableRecovery: common.ToPtr(true), - DisableSubmenu: common.ToPtr(true), - Distributor: "$(sed 's, release .*$,,g' /etc/system-release)", - Terminal: []string{"serial", "console"}, - Serial: "serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1", - Timeout: 10, - TimeoutStyle: osbuild.GRUB2ConfigTimeoutStyleCountdown, - }, - UdevRules: &osbuild.UdevRulesStageOptions{ - Filename: "/etc/udev/rules.d/68-azure-sriov-nm-unmanaged.rules", - Rules: osbuild.UdevRules{ - osbuild.UdevRuleComment{ - Comment: []string{ - "Accelerated Networking on Azure exposes a new SRIOV interface to the VM.", - "This interface is transparently bonded to the synthetic interface,", - "so NetworkManager should just ignore any SRIOV interfaces.", + Grub2Config: &osbuild.GRUB2Config{ + DisableRecovery: common.ToPtr(true), + DisableSubmenu: common.ToPtr(true), + Distributor: "$(sed 's, release .*$,,g' /etc/system-release)", + Terminal: []string{"serial", "console"}, + Serial: "serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1", + Timeout: 10, + TimeoutStyle: osbuild.GRUB2ConfigTimeoutStyleCountdown, + }, + UdevRules: &osbuild.UdevRulesStageOptions{ + Filename: "/etc/udev/rules.d/68-azure-sriov-nm-unmanaged.rules", + Rules: osbuild.UdevRules{ + osbuild.UdevRuleComment{ + Comment: []string{ + "Accelerated Networking on Azure exposes a new SRIOV interface to the VM.", + "This interface is transparently bonded to the synthetic interface,", + "so NetworkManager should just ignore any SRIOV interfaces.", + }, }, + osbuild.NewUdevRule( + []osbuild.UdevKV{ + {K: "SUBSYSTEM", O: "==", V: "net"}, + {K: "DRIVERS", O: "==", V: "hv_pci"}, + {K: "ACTION", O: "==", V: "add"}, + {K: "ENV", A: "NM_UNMANAGED", O: "=", V: "1"}, + }, + ), }, - osbuild.NewUdevRule( - []osbuild.UdevKV{ - {K: "SUBSYSTEM", O: "==", V: "net"}, - {K: "DRIVERS", O: "==", V: "hv_pci"}, - {K: "ACTION", O: "==", V: "add"}, - {K: "ENV", A: "NM_UNMANAGED", O: "=", V: "1"}, - }, - ), }, - }, - SystemdUnit: []*osbuild.SystemdUnitStageOptions{ - { - Unit: "nm-cloud-setup.service", - Dropin: "10-rh-enable-for-azure.conf", - Config: osbuild.SystemdServiceUnitDropin{ - Service: &osbuild.SystemdUnitServiceSection{ - Environment: []osbuild.EnvironmentVariable{{Key: "NM_CLOUD_SETUP_AZURE", Value: "yes"}}, + SystemdUnit: []*osbuild.SystemdUnitStageOptions{ + { + Unit: "nm-cloud-setup.service", + Dropin: "10-rh-enable-for-azure.conf", + Config: osbuild.SystemdServiceUnitDropin{ + Service: &osbuild.SystemdUnitServiceSection{ + Environment: []osbuild.EnvironmentVariable{{Key: "NM_CLOUD_SETUP_AZURE", Value: "yes"}}, + }, }, }, }, - }, - DefaultTarget: common.ToPtr("multi-user.target"), + DefaultTarget: common.ToPtr("multi-user.target"), + } + return ic } diff --git a/pkg/distro/rhel/rhel10/distro.go b/pkg/distro/rhel/rhel10/distro.go index 3d4c243e35..3bbc92e34f 100644 --- a/pkg/distro/rhel/rhel10/distro.go +++ b/pkg/distro/rhel/rhel10/distro.go @@ -208,13 +208,8 @@ func newDistro(name string, major, minor int) *rhel.Distribution { }, } - if rd.IsRHEL() { // RHEL-only (non-CentOS) image types - x86_64.AddImageTypes(azureX64Platform, mkAzureByosImgType(rd)) - aarch64.AddImageTypes(azureAarch64Platform, mkAzureByosImgType(rd)) - } else { - x86_64.AddImageTypes(azureX64Platform, mkAzureImgType()) - aarch64.AddImageTypes(azureAarch64Platform, mkAzureImgType()) - } + x86_64.AddImageTypes(azureX64Platform, mkAzureImgType(rd)) + aarch64.AddImageTypes(azureAarch64Platform, mkAzureImgType(rd)) gceX86Platform := &platform.X86{ UEFIVendor: rd.Vendor(), From e216d76195e214817027dec7d6a77a93d3d36139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 13:10:37 +0100 Subject: [PATCH 02/12] RHEL-10/Azure: import the RH RPM GPG key by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I'm not sure if this was initially missed for RHEL-10, but the RHEL-9 VHD image imports the RHEL RPM GPG key by default. There's no good reason to not do the same on RHEL-10. Fix the image definition. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/azure.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/distro/rhel/rhel10/azure.go b/pkg/distro/rhel/rhel10/azure.go index be58220193..4858562125 100644 --- a/pkg/distro/rhel/rhel10/azure.go +++ b/pkg/distro/rhel/rhel10/azure.go @@ -278,5 +278,10 @@ func defaultAzureImageConfig(rd *rhel.Distribution) *distro.ImageConfig { }, DefaultTarget: common.ToPtr("multi-user.target"), } + + if rd.IsRHEL() { + ic.GPGKeyFiles = append(ic.GPGKeyFiles, "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release") + } + return ic } From 943500113d4481c3537ad221420e38830cdbb2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 13:33:03 +0100 Subject: [PATCH 03/12] RHEL-10: add `azure-rhui` RHEL-only image type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The image definition is based on RHEL-9. The image type default PT is LVM-based and has `/boot` on a separate partition, because we don't support `/boot` on LVM. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/azure.go | 249 ++++++++++++++++++ pkg/distro/rhel/rhel10/distro.go | 5 + .../rhel/rhel10/distro_internal_test.go | 5 + pkg/distro/rhel/rhel10/distro_test.go | 2 + 4 files changed, 261 insertions(+) diff --git a/pkg/distro/rhel/rhel10/azure.go b/pkg/distro/rhel/rhel10/azure.go index 4858562125..933665238f 100644 --- a/pkg/distro/rhel/rhel10/azure.go +++ b/pkg/distro/rhel/rhel10/azure.go @@ -2,7 +2,9 @@ package rhel10 import ( "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/arch" "github.com/osbuild/images/pkg/datasizes" + "github.com/osbuild/images/pkg/disk" "github.com/osbuild/images/pkg/distro" "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/osbuild" @@ -33,6 +35,31 @@ func mkAzureImgType(rd *rhel.Distribution) *rhel.ImageType { return it } +// Azure RHEL-internal image type +func mkAzureInternalImgType(rd *rhel.Distribution) *rhel.ImageType { + it := rhel.NewImageType( + "azure-rhui", + "disk.vhd.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: azurePackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vpc", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = defaultAzureKernelOptions + it.Bootable = true + it.DefaultSize = 64 * datasizes.GibiByte + it.DefaultImageConfig = defaultAzureImageConfig(rd) + it.BasePartitionTables = azureInternalBasePartitionTables + + return it +} + // PACKAGE SETS // Common Azure image package set @@ -119,6 +146,228 @@ func azurePackageSet(t *rhel.ImageType) rpmmd.PackageSet { return azureCommonPackageSet(t) } +// PARTITION TABLES +func azureInternalBasePartitionTables(t *rhel.ImageType) (disk.PartitionTable, bool) { + switch t.Arch().Name() { + case arch.ARCH_X86_64.String(): + return disk.PartitionTable{ + UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", + Type: disk.PT_GPT, + Size: 64 * datasizes.GibiByte, + Partitions: []disk.Partition{ + { + Size: 500 * datasizes.MebiByte, + Type: disk.EFISystemPartitionGUID, + UUID: disk.EFISystemPartitionUUID, + Payload: &disk.Filesystem{ + Type: "vfat", + UUID: disk.EFIFilesystemUUID, + Mountpoint: "/boot/efi", + FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", + FSTabFreq: 0, + FSTabPassNo: 2, + }, + }, + // NB: we currently don't support /boot on LVM + { + Size: 1 * datasizes.GibiByte, + Type: disk.FilesystemDataGUID, + UUID: disk.FilesystemDataUUID, + Payload: &disk.Filesystem{ + Type: "xfs", + Mountpoint: "/boot", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * datasizes.MebiByte, + Bootable: true, + Type: disk.BIOSBootPartitionGUID, + UUID: disk.BIOSBootPartitionUUID, + }, + { + Type: disk.LVMPartitionGUID, + UUID: disk.RootPartitionUUID, + Payload: &disk.LVMVolumeGroup{ + Name: "rootvg", + Description: "built with lvm2 and osbuild", + LogicalVolumes: []disk.LVMLogicalVolume{ + { + Size: 1 * datasizes.GibiByte, + Name: "homelv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "home", + Mountpoint: "/home", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * datasizes.GibiByte, + Name: "rootlv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "root", + Mountpoint: "/", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * datasizes.GibiByte, + Name: "tmplv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "tmp", + Mountpoint: "/tmp", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 10 * datasizes.GibiByte, + Name: "usrlv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "usr", + Mountpoint: "/usr", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 10 * datasizes.GibiByte, + Name: "varlv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "var", + Mountpoint: "/var", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + }, + }, + }, + }, + }, true + case arch.ARCH_AARCH64.String(): + return disk.PartitionTable{ + UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", + Type: disk.PT_GPT, + Size: 64 * datasizes.GibiByte, + Partitions: []disk.Partition{ + { + Size: 500 * datasizes.MebiByte, + Type: disk.EFISystemPartitionGUID, + UUID: disk.EFISystemPartitionUUID, + Payload: &disk.Filesystem{ + Type: "vfat", + UUID: disk.EFIFilesystemUUID, + Mountpoint: "/boot/efi", + FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", + FSTabFreq: 0, + FSTabPassNo: 2, + }, + }, + // NB: we currently don't support /boot on LVM + { + Size: 1 * datasizes.GibiByte, + Type: disk.FilesystemDataGUID, + UUID: disk.FilesystemDataUUID, + Payload: &disk.Filesystem{ + Type: "xfs", + Mountpoint: "/boot", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Type: disk.LVMPartitionGUID, + UUID: disk.RootPartitionUUID, + Payload: &disk.LVMVolumeGroup{ + Name: "rootvg", + Description: "built with lvm2 and osbuild", + LogicalVolumes: []disk.LVMLogicalVolume{ + { + Size: 1 * datasizes.GibiByte, + Name: "homelv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "home", + Mountpoint: "/home", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * datasizes.GibiByte, + Name: "rootlv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "root", + Mountpoint: "/", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * datasizes.GibiByte, + Name: "tmplv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "tmp", + Mountpoint: "/tmp", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 10 * datasizes.GibiByte, + Name: "usrlv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "usr", + Mountpoint: "/usr", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 10 * datasizes.GibiByte, + Name: "varlv", + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "var", + Mountpoint: "/var", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + }, + }, + }, + }, + }, true + default: + return disk.PartitionTable{}, false + } +} + // IMAGE CONFIG // use loglevel=3 as described in the RHEL documentation and used in existing RHEL images built by MSFT diff --git a/pkg/distro/rhel/rhel10/distro.go b/pkg/distro/rhel/rhel10/distro.go index 3bbc92e34f..bd7616f602 100644 --- a/pkg/distro/rhel/rhel10/distro.go +++ b/pkg/distro/rhel/rhel10/distro.go @@ -253,6 +253,11 @@ func newDistro(name string, major, minor int) *rhel.Distribution { mkImageInstallerImgType(), ) + if rd.IsRHEL() { // RHEL-only (non-CentOS) image types + x86_64.AddImageTypes(azureX64Platform, mkAzureInternalImgType(rd)) + aarch64.AddImageTypes(azureAarch64Platform, mkAzureInternalImgType(rd)) + } + rd.AddArches(x86_64, aarch64, ppc64le, s390x) return rd } diff --git a/pkg/distro/rhel/rhel10/distro_internal_test.go b/pkg/distro/rhel/rhel10/distro_internal_test.go index 5ac98502d3..92a04ee0d7 100644 --- a/pkg/distro/rhel/rhel10/distro_internal_test.go +++ b/pkg/distro/rhel/rhel10/distro_internal_test.go @@ -176,6 +176,11 @@ func TestRhel10_NoBootPartition(t *testing.T) { if it.BasePartitionTables == nil { continue } + if it.Name() == "azure-rhui" { + // Azure RHEL internal image type PT is by default LVM-based + // and we do not support /boot on LVM, so it must be on a separate partition. + continue + } pt, err := it.GetPartitionTable([]blueprint.FilesystemCustomization{}, distro.ImageOptions{}, rng) assert.NoError(t, err) _, err = pt.GetMountpointSize("/boot") diff --git a/pkg/distro/rhel/rhel10/distro_test.go b/pkg/distro/rhel/rhel10/distro_test.go index 2b9ff75d9c..97c3d8c463 100644 --- a/pkg/distro/rhel/rhel10/distro_test.go +++ b/pkg/distro/rhel/rhel10/distro_test.go @@ -282,6 +282,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) { "wsl", "gce", "image-installer", + "azure-rhui", }, }, { @@ -293,6 +294,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) { "vhd", "wsl", "image-installer", + "azure-rhui", }, }, { From 0a987fa2282d7d37a0fc4f2d38a7bee9c1fd1a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 13:33:03 +0100 Subject: [PATCH 04/12] RHEL-10: add `azure-sap-rhui` RHEL-only image type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The image definition is based on RHEL-9. The image type default PT is LVM-based and has `/boot` on a separate partition, because we don't support `/boot` on LVM. The `gtk2` package has been commented out from the default SAP package set, because it is not available on RHEL-10. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/azure.go | 34 ++++ pkg/distro/rhel/rhel10/distro.go | 2 + .../rhel/rhel10/distro_internal_test.go | 2 +- pkg/distro/rhel/rhel10/distro_test.go | 1 + pkg/distro/rhel/rhel10/sap.go | 174 ++++++++++++++++++ 5 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 pkg/distro/rhel/rhel10/sap.go diff --git a/pkg/distro/rhel/rhel10/azure.go b/pkg/distro/rhel/rhel10/azure.go index 933665238f..7f10832881 100644 --- a/pkg/distro/rhel/rhel10/azure.go +++ b/pkg/distro/rhel/rhel10/azure.go @@ -60,6 +60,30 @@ func mkAzureInternalImgType(rd *rhel.Distribution) *rhel.ImageType { return it } +func mkAzureSapInternalImgType(rd *rhel.Distribution) *rhel.ImageType { + it := rhel.NewImageType( + "azure-sap-rhui", + "disk.vhd.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: azureSapPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vpc", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = defaultAzureKernelOptions + it.Bootable = true + it.DefaultSize = 64 * datasizes.GibiByte + it.DefaultImageConfig = sapAzureImageConfig(rd) + it.BasePartitionTables = azureInternalBasePartitionTables + + return it +} + // PACKAGE SETS // Common Azure image package set @@ -146,6 +170,12 @@ func azurePackageSet(t *rhel.ImageType) rpmmd.PackageSet { return azureCommonPackageSet(t) } +// Azure SAP image package set +// Includes the common azure package set, the common SAP packages +func azureSapPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + return azureCommonPackageSet(t).Append(SapPackageSet(t)) +} + // PARTITION TABLES func azureInternalBasePartitionTables(t *rhel.ImageType) (disk.PartitionTable, bool) { switch t.Arch().Name() { @@ -534,3 +564,7 @@ func defaultAzureImageConfig(rd *rhel.Distribution) *distro.ImageConfig { return ic } + +func sapAzureImageConfig(rd *rhel.Distribution) *distro.ImageConfig { + return sapImageConfig(rd.OsVersion()).InheritFrom(defaultAzureImageConfig(rd)) +} diff --git a/pkg/distro/rhel/rhel10/distro.go b/pkg/distro/rhel/rhel10/distro.go index bd7616f602..353a37c776 100644 --- a/pkg/distro/rhel/rhel10/distro.go +++ b/pkg/distro/rhel/rhel10/distro.go @@ -256,6 +256,8 @@ func newDistro(name string, major, minor int) *rhel.Distribution { if rd.IsRHEL() { // RHEL-only (non-CentOS) image types x86_64.AddImageTypes(azureX64Platform, mkAzureInternalImgType(rd)) aarch64.AddImageTypes(azureAarch64Platform, mkAzureInternalImgType(rd)) + + x86_64.AddImageTypes(azureX64Platform, mkAzureSapInternalImgType(rd)) } rd.AddArches(x86_64, aarch64, ppc64le, s390x) diff --git a/pkg/distro/rhel/rhel10/distro_internal_test.go b/pkg/distro/rhel/rhel10/distro_internal_test.go index 92a04ee0d7..4315939822 100644 --- a/pkg/distro/rhel/rhel10/distro_internal_test.go +++ b/pkg/distro/rhel/rhel10/distro_internal_test.go @@ -176,7 +176,7 @@ func TestRhel10_NoBootPartition(t *testing.T) { if it.BasePartitionTables == nil { continue } - if it.Name() == "azure-rhui" { + if it.Name() == "azure-rhui" || it.Name() == "azure-sap-rhui" { // Azure RHEL internal image type PT is by default LVM-based // and we do not support /boot on LVM, so it must be on a separate partition. continue diff --git a/pkg/distro/rhel/rhel10/distro_test.go b/pkg/distro/rhel/rhel10/distro_test.go index 97c3d8c463..e8467b714f 100644 --- a/pkg/distro/rhel/rhel10/distro_test.go +++ b/pkg/distro/rhel/rhel10/distro_test.go @@ -283,6 +283,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) { "gce", "image-installer", "azure-rhui", + "azure-sap-rhui", }, }, { diff --git a/pkg/distro/rhel/rhel10/sap.go b/pkg/distro/rhel/rhel10/sap.go new file mode 100644 index 0000000000..1290bb2d63 --- /dev/null +++ b/pkg/distro/rhel/rhel10/sap.go @@ -0,0 +1,174 @@ +package rhel10 + +import ( + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" +) + +// sapImageConfig returns the SAP specific ImageConfig data +func sapImageConfig(osVersion string) *distro.ImageConfig { + return &distro.ImageConfig{ + SELinuxConfig: &osbuild.SELinuxConfigStageOptions{ + State: osbuild.SELinuxStatePermissive, + }, + // RHBZ#1960617 + Tuned: osbuild.NewTunedStageOptions("sap-hana"), + // RHBZ#1959979 + Tmpfilesd: []*osbuild.TmpfilesdStageOptions{ + osbuild.NewTmpfilesdStageOptions("sap.conf", + []osbuild.TmpfilesdConfigLine{ + { + Type: "x", + Path: "/tmp/.sap*", + }, + { + Type: "x", + Path: "/tmp/.hdb*lock", + }, + { + Type: "x", + Path: "/tmp/.trex*lock", + }, + }, + ), + }, + // RHBZ#1959963 + PamLimitsConf: []*osbuild.PamLimitsConfStageOptions{ + osbuild.NewPamLimitsConfStageOptions("99-sap.conf", + []osbuild.PamLimitsConfigLine{ + { + Domain: "@sapsys", + Type: osbuild.PamLimitsTypeHard, + Item: osbuild.PamLimitsItemNofile, + Value: osbuild.PamLimitsValueInt(1048576), + }, + { + Domain: "@sapsys", + Type: osbuild.PamLimitsTypeSoft, + Item: osbuild.PamLimitsItemNofile, + Value: osbuild.PamLimitsValueInt(1048576), + }, + { + Domain: "@dba", + Type: osbuild.PamLimitsTypeHard, + Item: osbuild.PamLimitsItemNofile, + Value: osbuild.PamLimitsValueInt(1048576), + }, + { + Domain: "@dba", + Type: osbuild.PamLimitsTypeSoft, + Item: osbuild.PamLimitsItemNofile, + Value: osbuild.PamLimitsValueInt(1048576), + }, + { + Domain: "@sapsys", + Type: osbuild.PamLimitsTypeHard, + Item: osbuild.PamLimitsItemNproc, + Value: osbuild.PamLimitsValueUnlimited, + }, + { + Domain: "@sapsys", + Type: osbuild.PamLimitsTypeSoft, + Item: osbuild.PamLimitsItemNproc, + Value: osbuild.PamLimitsValueUnlimited, + }, + { + Domain: "@dba", + Type: osbuild.PamLimitsTypeHard, + Item: osbuild.PamLimitsItemNproc, + Value: osbuild.PamLimitsValueUnlimited, + }, + { + Domain: "@dba", + Type: osbuild.PamLimitsTypeSoft, + Item: osbuild.PamLimitsItemNproc, + Value: osbuild.PamLimitsValueUnlimited, + }, + }, + ), + }, + // RHBZ#1959962 + Sysctld: []*osbuild.SysctldStageOptions{ + osbuild.NewSysctldStageOptions("sap.conf", + []osbuild.SysctldConfigLine{ + { + Key: "kernel.pid_max", + Value: "4194304", + }, + { + Key: "vm.max_map_count", + Value: "2147483647", + }, + }, + ), + }, + // E4S/EUS + DNFConfig: []*osbuild.DNFConfigStageOptions{ + osbuild.NewDNFConfigStageOptions( + []osbuild.DNFVariable{ + { + Name: "releasever", + Value: osVersion, + }, + }, + nil, + ), + }, + } +} + +func SapPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + return rpmmd.PackageSet{ + Include: []string{ + // RHBZ#2076763 + "@Server", + // SAP System Roles + // https://access.redhat.com/sites/default/files/attachments/rhel_system_roles_for_sap_1.pdf + "ansible-core", + "rhel-system-roles-sap", + // RHBZ#1959813 + "bind-utils", + "nfs-utils", + "tcsh", + // RHBZ#1959955 + "uuidd", + // RHBZ#1959923 + "cairo", + "expect", + "graphviz", + //"gtk2", // gtk2 is not available in RHEL-10 + "iptraf-ng", + "krb5-workstation", + "libaio", + "libatomic", + "libicu", + "libtool-ltdl", + "lm_sensors", + "net-tools", + "numactl", + "PackageKit-gtk3-module", + "xorg-x11-xauth", + // RHBZ#1960617 + "tuned-profiles-sap-hana", + // RHBZ#1961168 + "libnsl", + }, + Exclude: []string{ + "iwl1000-firmware", + "iwl100-firmware", + "iwl105-firmware", + "iwl135-firmware", + "iwl2000-firmware", + "iwl2030-firmware", + "iwl3160-firmware", + "iwl5000-firmware", + "iwl5150-firmware", + "iwl6000g2a-firmware", + "iwl6000g2b-firmware", + "iwl6050-firmware", + "iwl7260-firmware", + }, + } +} From 1346488c461d8278a26b7c5ee839a84449b86565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 14:45:52 +0100 Subject: [PATCH 05/12] RHEL-10/AMI: don't define special build package set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no reason to define a separate build package set for any EC2 images, because any required packages will be automatically added to the build pipeline pkgset by the pipeline implementation. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/ami.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/pkg/distro/rhel/rhel10/ami.go b/pkg/distro/rhel/rhel10/ami.go index 61b0c7613d..216e7f124f 100644 --- a/pkg/distro/rhel/rhel10/ami.go +++ b/pkg/distro/rhel/rhel10/ami.go @@ -135,16 +135,6 @@ func defaultAMIImageConfigX86_64() *distro.ImageConfig { return appendEC2DracutX86_64(ic) } -// common ec2 image build package set -func ec2BuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { - return distroBuildPackageSet(t).Append( - rpmmd.PackageSet{ - Include: []string{ - "python3-pyyaml", - }, - }) -} - func ec2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ @@ -231,8 +221,7 @@ func mkAMIImgTypeAarch64() *rhel.ImageType { "image.raw", "application/octet-stream", map[string]rhel.PackageSetFunc{ - rhel.BuildPkgsKey: ec2BuildPackageSet, - rhel.OSPkgsKey: ec2CommonPackageSet, + rhel.OSPkgsKey: ec2CommonPackageSet, }, rhel.DiskImage, []string{"build"}, From 44ef3a645b81a7e1af259281fd12f67284c50460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 14:54:50 +0100 Subject: [PATCH 06/12] RHEL-10/AMI: move definitions to be similar to Azure ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move function definitions within the file to be in a similar order and structure as the Azure definitions file. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/ami.go | 124 ++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 60 deletions(-) diff --git a/pkg/distro/rhel/rhel10/ami.go b/pkg/distro/rhel/rhel10/ami.go index 216e7f124f..ce32f01158 100644 --- a/pkg/distro/rhel/rhel10/ami.go +++ b/pkg/distro/rhel/rhel10/ami.go @@ -9,6 +9,54 @@ import ( "github.com/osbuild/images/pkg/rpmmd" ) +func mkAMIImgTypeX86_64() *rhel.ImageType { + it := rhel.NewImageType( + "ami", + "image.raw", + "application/octet-stream", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: ec2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image"}, + []string{"image"}, + ) + + it.KernelOptions = amiKernelOptions + it.Bootable = true + it.DefaultSize = 10 * datasizes.GibiByte + it.DefaultImageConfig = defaultAMIImageConfigX86_64() + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func mkAMIImgTypeAarch64() *rhel.ImageType { + it := rhel.NewImageType( + "ami", + "image.raw", + "application/octet-stream", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: ec2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image"}, + []string{"image"}, + ) + + it.KernelOptions = "console=ttyS0,115200n8 console=tty0 nvme_core.io_timeout=4294967295 iommu.strict=0" + it.Bootable = true + it.DefaultSize = 10 * datasizes.GibiByte + it.DefaultImageConfig = defaultAMIImageConfig() + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +// IMAGE CONFIG + // TODO: move these to the EC2 environment const amiKernelOptions = "console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295" @@ -127,6 +175,20 @@ func defaultAMIImageConfig() *distro.ImageConfig { return baseEc2ImageConfig() } +func appendEC2DracutX86_64(ic *distro.ImageConfig) *distro.ImageConfig { + ic.DracutConf = append(ic.DracutConf, + &osbuild.DracutConfStageOptions{ + Filename: "ec2.conf", + Config: osbuild.DracutConfigFile{ + AddDrivers: []string{ + "nvme", + "xen-blkfront", + }, + }, + }) + return ic +} + // Default AMI x86_64 (custom image built by users) images config. // The configuration does not touch the RHSM configuration at all. // https://issues.redhat.com/browse/COMPOSER-2157 @@ -135,6 +197,8 @@ func defaultAMIImageConfigX86_64() *distro.ImageConfig { return appendEC2DracutX86_64(ic) } +// PACKAGE SETS + func ec2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ @@ -191,63 +255,3 @@ func ec2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return ps } - -func mkAMIImgTypeX86_64() *rhel.ImageType { - it := rhel.NewImageType( - "ami", - "image.raw", - "application/octet-stream", - map[string]rhel.PackageSetFunc{ - rhel.OSPkgsKey: ec2CommonPackageSet, - }, - rhel.DiskImage, - []string{"build"}, - []string{"os", "image"}, - []string{"image"}, - ) - - it.KernelOptions = amiKernelOptions - it.Bootable = true - it.DefaultSize = 10 * datasizes.GibiByte - it.DefaultImageConfig = defaultAMIImageConfigX86_64() - it.BasePartitionTables = defaultBasePartitionTables - - return it -} - -func mkAMIImgTypeAarch64() *rhel.ImageType { - it := rhel.NewImageType( - "ami", - "image.raw", - "application/octet-stream", - map[string]rhel.PackageSetFunc{ - rhel.OSPkgsKey: ec2CommonPackageSet, - }, - rhel.DiskImage, - []string{"build"}, - []string{"os", "image"}, - []string{"image"}, - ) - - it.KernelOptions = "console=ttyS0,115200n8 console=tty0 nvme_core.io_timeout=4294967295 iommu.strict=0" - it.Bootable = true - it.DefaultSize = 10 * datasizes.GibiByte - it.DefaultImageConfig = defaultAMIImageConfig() - it.BasePartitionTables = defaultBasePartitionTables - - return it -} - -func appendEC2DracutX86_64(ic *distro.ImageConfig) *distro.ImageConfig { - ic.DracutConf = append(ic.DracutConf, - &osbuild.DracutConfStageOptions{ - Filename: "ec2.conf", - Config: osbuild.DracutConfigFile{ - AddDrivers: []string{ - "nvme", - "xen-blkfront", - }, - }, - }) - return ic -} From 35288db04f6d9f643b44cf1f2e902c9f5221258e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 16:11:56 +0100 Subject: [PATCH 07/12] RHEL-10/AMI: refactor AMI kernel options constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The constants used for kernel options for EC2 images share some parts. Let's refactor them to make differences easier to spot. Also don't use string literals on multiple places. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/ami.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/distro/rhel/rhel10/ami.go b/pkg/distro/rhel/rhel10/ami.go index ce32f01158..c69e38cc15 100644 --- a/pkg/distro/rhel/rhel10/ami.go +++ b/pkg/distro/rhel/rhel10/ami.go @@ -46,7 +46,7 @@ func mkAMIImgTypeAarch64() *rhel.ImageType { []string{"image"}, ) - it.KernelOptions = "console=ttyS0,115200n8 console=tty0 nvme_core.io_timeout=4294967295 iommu.strict=0" + it.KernelOptions = amiAarch64KernelOptions it.Bootable = true it.DefaultSize = 10 * datasizes.GibiByte it.DefaultImageConfig = defaultAMIImageConfig() @@ -58,7 +58,10 @@ func mkAMIImgTypeAarch64() *rhel.ImageType { // IMAGE CONFIG // TODO: move these to the EC2 environment -const amiKernelOptions = "console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295" +const ( + amiKernelOptions = "console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295" + amiAarch64KernelOptions = amiKernelOptions + " iommu.strict=0" +) // default EC2 images config (common for all architectures) func baseEc2ImageConfig() *distro.ImageConfig { From 83d4b879f24c0c977dd20a00d79061cb6638f64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 16:30:53 +0100 Subject: [PATCH 08/12] RHEL-10/AMI: sync function names with RHEL-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RHEL-9 AMI has been reworked as part of the RHSM auto-reg v2, which resulted in all RHSM and RHUI specific parts to be removed from the image definitions. This allowed to simplify them and some functions were renamed as part of it. Carry over the function names used in RHEL-9 to RHEL-10, to make things more consistent across these distributions. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/ami.go | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/pkg/distro/rhel/rhel10/ami.go b/pkg/distro/rhel/rhel10/ami.go index c69e38cc15..7b792a9407 100644 --- a/pkg/distro/rhel/rhel10/ami.go +++ b/pkg/distro/rhel/rhel10/ami.go @@ -15,7 +15,7 @@ func mkAMIImgTypeX86_64() *rhel.ImageType { "image.raw", "application/octet-stream", map[string]rhel.PackageSetFunc{ - rhel.OSPkgsKey: ec2CommonPackageSet, + rhel.OSPkgsKey: ec2PackageSet, }, rhel.DiskImage, []string{"build"}, @@ -26,7 +26,7 @@ func mkAMIImgTypeX86_64() *rhel.ImageType { it.KernelOptions = amiKernelOptions it.Bootable = true it.DefaultSize = 10 * datasizes.GibiByte - it.DefaultImageConfig = defaultAMIImageConfigX86_64() + it.DefaultImageConfig = defaultEc2ImageConfigX86_64() it.BasePartitionTables = defaultBasePartitionTables return it @@ -38,7 +38,7 @@ func mkAMIImgTypeAarch64() *rhel.ImageType { "image.raw", "application/octet-stream", map[string]rhel.PackageSetFunc{ - rhel.OSPkgsKey: ec2CommonPackageSet, + rhel.OSPkgsKey: ec2PackageSet, }, rhel.DiskImage, []string{"build"}, @@ -49,7 +49,7 @@ func mkAMIImgTypeAarch64() *rhel.ImageType { it.KernelOptions = amiAarch64KernelOptions it.Bootable = true it.DefaultSize = 10 * datasizes.GibiByte - it.DefaultImageConfig = defaultAMIImageConfig() + it.DefaultImageConfig = defaultEc2ImageConfig() it.BasePartitionTables = defaultBasePartitionTables return it @@ -64,7 +64,7 @@ const ( ) // default EC2 images config (common for all architectures) -func baseEc2ImageConfig() *distro.ImageConfig { +func defaultEc2ImageConfig() *distro.ImageConfig { return &distro.ImageConfig{ Locale: common.ToPtr("en_US.UTF-8"), Timezone: common.ToPtr("UTC"), @@ -171,13 +171,6 @@ func baseEc2ImageConfig() *distro.ImageConfig { } } -// Default AMI (custom image built by users) images config. -// The configuration does not touch the RHSM configuration at all. -// https://issues.redhat.com/browse/COMPOSER-2157 -func defaultAMIImageConfig() *distro.ImageConfig { - return baseEc2ImageConfig() -} - func appendEC2DracutX86_64(ic *distro.ImageConfig) *distro.ImageConfig { ic.DracutConf = append(ic.DracutConf, &osbuild.DracutConfStageOptions{ @@ -192,17 +185,14 @@ func appendEC2DracutX86_64(ic *distro.ImageConfig) *distro.ImageConfig { return ic } -// Default AMI x86_64 (custom image built by users) images config. -// The configuration does not touch the RHSM configuration at all. -// https://issues.redhat.com/browse/COMPOSER-2157 -func defaultAMIImageConfigX86_64() *distro.ImageConfig { - ic := defaultAMIImageConfig() +func defaultEc2ImageConfigX86_64() *distro.ImageConfig { + ic := defaultEc2ImageConfig() return appendEC2DracutX86_64(ic) } // PACKAGE SETS -func ec2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { +func ec2PackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "@core", From 71cb53c38cdf45ea73ded923233255a4d11df5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 16:40:48 +0100 Subject: [PATCH 09/12] RHEL-10: define ec2Aarch64Platform and use it everywhere MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Define a common ec2Aarch64Platform and use it everywhere in the future when there will be more than one EC2 Aarch64 image types. Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/distro.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/distro/rhel/rhel10/distro.go b/pkg/distro/rhel/rhel10/distro.go index 353a37c776..b49f10bbb0 100644 --- a/pkg/distro/rhel/rhel10/distro.go +++ b/pkg/distro/rhel/rhel10/distro.go @@ -183,13 +183,14 @@ func newDistro(name string, major, minor int) *rhel.Distribution { mkAMIImgTypeX86_64(), ) - aarch64.AddImageTypes( - &platform.Aarch64{ - UEFIVendor: rd.Vendor(), - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_RAW, - }, + ec2Aarch64Platform := &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, }, + } + aarch64.AddImageTypes( + ec2Aarch64Platform, mkAMIImgTypeAarch64(), ) From 483a2fbf0ad06ac49d2ad30c5805320cf0abc706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 16:43:23 +0100 Subject: [PATCH 10/12] RHEL-10: add internal-only `ec2` image type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/ami.go | 50 +++++++++++++++++++++++++++ pkg/distro/rhel/rhel10/distro.go | 3 ++ pkg/distro/rhel/rhel10/distro_test.go | 2 ++ 3 files changed, 55 insertions(+) diff --git a/pkg/distro/rhel/rhel10/ami.go b/pkg/distro/rhel/rhel10/ami.go index 7b792a9407..7ff795d6b0 100644 --- a/pkg/distro/rhel/rhel10/ami.go +++ b/pkg/distro/rhel/rhel10/ami.go @@ -55,6 +55,56 @@ func mkAMIImgTypeAarch64() *rhel.ImageType { return it } +// RHEL internal-only x86_64 EC2 image type +func mkEc2ImgTypeX86_64() *rhel.ImageType { + it := rhel.NewImageType( + "ec2", + "image.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: ec2PackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = amiKernelOptions + it.Bootable = true + it.DefaultSize = 10 * datasizes.GibiByte + it.DefaultImageConfig = defaultEc2ImageConfigX86_64() + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +// RHEL internal-only aarch64 EC2 image type +func mkEC2ImgTypeAarch64() *rhel.ImageType { + it := rhel.NewImageType( + "ec2", + "image.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: ec2PackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = amiAarch64KernelOptions + it.Bootable = true + it.DefaultSize = 10 * datasizes.GibiByte + it.DefaultImageConfig = defaultEc2ImageConfig() + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + // IMAGE CONFIG // TODO: move these to the EC2 environment diff --git a/pkg/distro/rhel/rhel10/distro.go b/pkg/distro/rhel/rhel10/distro.go index b49f10bbb0..869b91a432 100644 --- a/pkg/distro/rhel/rhel10/distro.go +++ b/pkg/distro/rhel/rhel10/distro.go @@ -259,6 +259,9 @@ func newDistro(name string, major, minor int) *rhel.Distribution { aarch64.AddImageTypes(azureAarch64Platform, mkAzureInternalImgType(rd)) x86_64.AddImageTypes(azureX64Platform, mkAzureSapInternalImgType(rd)) + + x86_64.AddImageTypes(ec2X86Platform, mkEc2ImgTypeX86_64()) + aarch64.AddImageTypes(ec2Aarch64Platform, mkEC2ImgTypeAarch64()) } rd.AddArches(x86_64, aarch64, ppc64le, s390x) diff --git a/pkg/distro/rhel/rhel10/distro_test.go b/pkg/distro/rhel/rhel10/distro_test.go index e8467b714f..ce248d6c4a 100644 --- a/pkg/distro/rhel/rhel10/distro_test.go +++ b/pkg/distro/rhel/rhel10/distro_test.go @@ -284,6 +284,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) { "image-installer", "azure-rhui", "azure-sap-rhui", + "ec2", }, }, { @@ -296,6 +297,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) { "wsl", "image-installer", "azure-rhui", + "ec2", }, }, { From 9288c066ad8f34ab8e746a391db3efd9680b89e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 16:43:23 +0100 Subject: [PATCH 11/12] RHEL-10: add internal-only `ec2-ha` image type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/ami.go | 38 +++++++++++++++++++++++++++ pkg/distro/rhel/rhel10/distro.go | 2 +- pkg/distro/rhel/rhel10/distro_test.go | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/pkg/distro/rhel/rhel10/ami.go b/pkg/distro/rhel/rhel10/ami.go index 7ff795d6b0..3bb5e94acc 100644 --- a/pkg/distro/rhel/rhel10/ami.go +++ b/pkg/distro/rhel/rhel10/ami.go @@ -105,6 +105,31 @@ func mkEC2ImgTypeAarch64() *rhel.ImageType { return it } +// RHEL internal-only x86_64 EC2 HA image type +func mkEc2HaImgTypeX86_64() *rhel.ImageType { + it := rhel.NewImageType( + "ec2-ha", + "image.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: rhelEc2HaPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = amiKernelOptions + it.Bootable = true + it.DefaultSize = 10 * datasizes.GibiByte + it.DefaultImageConfig = defaultEc2ImageConfigX86_64() + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + // IMAGE CONFIG // TODO: move these to the EC2 environment @@ -298,3 +323,16 @@ func ec2PackageSet(t *rhel.ImageType) rpmmd.PackageSet { return ps } + +// rhel-ha-ec2 image package set +func rhelEc2HaPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ec2HaPackageSet := ec2PackageSet(t) + ec2HaPackageSet = ec2HaPackageSet.Append(rpmmd.PackageSet{ + Include: []string{ + "fence-agents-all", + "pacemaker", + "pcs", + }, + }) + return ec2HaPackageSet +} diff --git a/pkg/distro/rhel/rhel10/distro.go b/pkg/distro/rhel/rhel10/distro.go index 869b91a432..2934d36998 100644 --- a/pkg/distro/rhel/rhel10/distro.go +++ b/pkg/distro/rhel/rhel10/distro.go @@ -260,7 +260,7 @@ func newDistro(name string, major, minor int) *rhel.Distribution { x86_64.AddImageTypes(azureX64Platform, mkAzureSapInternalImgType(rd)) - x86_64.AddImageTypes(ec2X86Platform, mkEc2ImgTypeX86_64()) + x86_64.AddImageTypes(ec2X86Platform, mkEc2ImgTypeX86_64(), mkEc2HaImgTypeX86_64()) aarch64.AddImageTypes(ec2Aarch64Platform, mkEC2ImgTypeAarch64()) } diff --git a/pkg/distro/rhel/rhel10/distro_test.go b/pkg/distro/rhel/rhel10/distro_test.go index ce248d6c4a..02f69afdd4 100644 --- a/pkg/distro/rhel/rhel10/distro_test.go +++ b/pkg/distro/rhel/rhel10/distro_test.go @@ -285,6 +285,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) { "azure-rhui", "azure-sap-rhui", "ec2", + "ec2-ha", }, }, { From 8308f4c3f2a80cfc4276aa578ca82b3f1da8d60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 25 Nov 2024 16:43:23 +0100 Subject: [PATCH 12/12] RHEL-10: add internal-only `ec2-sap` image type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomáš Hozza --- pkg/distro/rhel/rhel10/ami.go | 34 +++++++++++++++++++++++++++ pkg/distro/rhel/rhel10/distro.go | 2 +- pkg/distro/rhel/rhel10/distro_test.go | 1 + test/config-map.json | 3 ++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/pkg/distro/rhel/rhel10/ami.go b/pkg/distro/rhel/rhel10/ami.go index 3bb5e94acc..2358791e9c 100644 --- a/pkg/distro/rhel/rhel10/ami.go +++ b/pkg/distro/rhel/rhel10/ami.go @@ -130,12 +130,37 @@ func mkEc2HaImgTypeX86_64() *rhel.ImageType { return it } +func mkEC2SapImgTypeX86_64(osVersion string) *rhel.ImageType { + it := rhel.NewImageType( + "ec2-sap", + "image.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: rhelEc2SapPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = amiSapKernelOptions + it.Bootable = true + it.DefaultSize = 10 * datasizes.GibiByte + it.DefaultImageConfig = sapImageConfig(osVersion).InheritFrom(defaultEc2ImageConfigX86_64()) + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + // IMAGE CONFIG // TODO: move these to the EC2 environment const ( amiKernelOptions = "console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295" amiAarch64KernelOptions = amiKernelOptions + " iommu.strict=0" + amiSapKernelOptions = amiKernelOptions + " processor.max_cstate=1 intel_idle.max_cstate=1" ) // default EC2 images config (common for all architectures) @@ -336,3 +361,12 @@ func rhelEc2HaPackageSet(t *rhel.ImageType) rpmmd.PackageSet { }) return ec2HaPackageSet } + +// rhel-sap-ec2 image package set +func rhelEc2SapPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + return rpmmd.PackageSet{ + Include: []string{ + //"libcanberra-gtk2", // libcanberra-gtk2 is not available in RHEL-10 + }, + }.Append(ec2PackageSet(t)).Append(SapPackageSet(t)) +} diff --git a/pkg/distro/rhel/rhel10/distro.go b/pkg/distro/rhel/rhel10/distro.go index 2934d36998..a5cd9b909d 100644 --- a/pkg/distro/rhel/rhel10/distro.go +++ b/pkg/distro/rhel/rhel10/distro.go @@ -260,7 +260,7 @@ func newDistro(name string, major, minor int) *rhel.Distribution { x86_64.AddImageTypes(azureX64Platform, mkAzureSapInternalImgType(rd)) - x86_64.AddImageTypes(ec2X86Platform, mkEc2ImgTypeX86_64(), mkEc2HaImgTypeX86_64()) + x86_64.AddImageTypes(ec2X86Platform, mkEc2ImgTypeX86_64(), mkEc2HaImgTypeX86_64(), mkEC2SapImgTypeX86_64(rd.OsVersion())) aarch64.AddImageTypes(ec2Aarch64Platform, mkEC2ImgTypeAarch64()) } diff --git a/pkg/distro/rhel/rhel10/distro_test.go b/pkg/distro/rhel/rhel10/distro_test.go index 02f69afdd4..ccbe2f73a6 100644 --- a/pkg/distro/rhel/rhel10/distro_test.go +++ b/pkg/distro/rhel/rhel10/distro_test.go @@ -286,6 +286,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) { "azure-sap-rhui", "ec2", "ec2-ha", + "ec2-sap", }, }, { diff --git a/test/config-map.json b/test/config-map.json index fa828e32d8..9c246ef87a 100644 --- a/test/config-map.json +++ b/test/config-map.json @@ -40,7 +40,8 @@ "rhel-8.7", "rhel-8.8", "rhel-8.9", - "rhel-9.*" + "rhel-9.*", + "rhel-10.*" ], "image-types": [ "ec2-sap"