diff --git a/pkg/distro/rhel9/ami.go b/pkg/distro/rhel9/ami.go index 578833f739..3df21cbfcb 100644 --- a/pkg/distro/rhel9/ami.go +++ b/pkg/distro/rhel9/ami.go @@ -189,7 +189,6 @@ func baseEc2ImageConfig() *distro.ImageConfig { { Filename: "00-getty-fixes.conf", Config: osbuild.SystemdLogindConfigDropin{ - Login: osbuild.SystemdLogindConfigLoginSection{ NAutoVTs: common.ToPtr(0), }, @@ -266,24 +265,23 @@ func defaultEc2ImageConfig(osVersion string, rhsm bool) *distro.ImageConfig { return ic } -// default AMI (EC2 BYOS) images config -func defaultAMIImageConfig(osVersion string, rhsm bool) *distro.ImageConfig { - ic := defaultEc2ImageConfig(osVersion, rhsm) - if rhsm { - // defaultEc2ImageConfig() adds the rhsm options only for RHEL < 9.1 - // Add it unconditionally for AMI - ic = appendRHSM(ic) - } - return ic -} - func defaultEc2ImageConfigX86_64(osVersion string, rhsm bool) *distro.ImageConfig { ic := defaultEc2ImageConfig(osVersion, rhsm) return appendEC2DracutX86_64(ic) } -func defaultAMIImageConfigX86_64(osVersion string, rhsm bool) *distro.ImageConfig { - ic := defaultAMIImageConfig(osVersion, rhsm).InheritFrom(defaultEc2ImageConfigX86_64(osVersion, rhsm)) +// 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() +} + +// 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() return appendEC2DracutX86_64(ic) } @@ -418,9 +416,9 @@ func mkEc2ImgTypeX86_64(osVersion string, rhsm bool) imageType { return it } -func mkAMIImgTypeX86_64(osVersion string, rhsm bool) imageType { +func mkAMIImgTypeX86_64() imageType { it := amiImgTypeX86_64 - ic := defaultAMIImageConfigX86_64(osVersion, rhsm) + ic := defaultAMIImageConfigX86_64() it.defaultImageConfig = ic return it } @@ -438,9 +436,9 @@ func mkEc2HaImgTypeX86_64(osVersion string, rhsm bool) imageType { return it } -func mkAMIImgTypeAarch64(osVersion string, rhsm bool) imageType { +func mkAMIImgTypeAarch64() imageType { it := amiImgTypeAarch64 - ic := defaultAMIImageConfig(osVersion, rhsm) + ic := defaultAMIImageConfig() it.defaultImageConfig = ic return it } diff --git a/pkg/distro/rhel9/azure.go b/pkg/distro/rhel9/azure.go index 25cf9ee49e..01e38175c2 100644 --- a/pkg/distro/rhel9/azure.go +++ b/pkg/distro/rhel9/azure.go @@ -572,35 +572,12 @@ var defaultAzureImageConfig = &distro.ImageConfig{ } // Diff of the default Image Config compare to the `defaultAzureImageConfig` +// The configuration for non-RHUI images does not touch the RHSM configuration at all. +// https://issues.redhat.com/browse/COMPOSER-2157 var defaultAzureByosImageConfig = &distro.ImageConfig{ GPGKeyFiles: []string{ "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release", }, - RHSMConfig: map[subscription.RHSMStatus]*osbuild.RHSMStageOptions{ - subscription.RHSMConfigNoSubscription: { - SubMan: &osbuild.RHSMStageOptionsSubMan{ - Rhsmcertd: &osbuild.SubManConfigRHSMCERTDSection{ - AutoRegistration: common.ToPtr(true), - }, - // Don't disable RHSM redhat.repo management on the GCE - // image, which is BYOS and does not use RHUI for content. - // Otherwise subscribing the system manually after booting - // it would result in empty redhat.repo. Without RHUI, such - // system would have no way to get Red Hat content, but - // enable the repo management manually, which would be very - // confusing. - }, - }, - subscription.RHSMConfigWithSubscription: { - SubMan: &osbuild.RHSMStageOptionsSubMan{ - Rhsmcertd: &osbuild.SubManConfigRHSMCERTDSection{ - AutoRegistration: common.ToPtr(true), - }, - // do not disable the redhat.repo management if the user - // explicitly request the system to be subscribed - }, - }, - }, } // Diff of the default Image Config compare to the `defaultAzureImageConfig` diff --git a/pkg/distro/rhel9/distro.go b/pkg/distro/rhel9/distro.go index a3b57a9880..6c32ec440a 100644 --- a/pkg/distro/rhel9/distro.go +++ b/pkg/distro/rhel9/distro.go @@ -253,7 +253,7 @@ func newDistro(name string, minor int) *distribution { } x86_64.addImageTypes( ec2X86Platform, - mkAMIImgTypeX86_64(rd.osVersion, rd.isRHEL()), + mkAMIImgTypeX86_64(), ) gceX86Platform := &platform.X86{ @@ -264,7 +264,7 @@ func newDistro(name string, minor int) *distribution { } x86_64.addImageTypes( gceX86Platform, - mkGCEImageType(rd.isRHEL()), + mkGCEImageType(), ) x86_64.addImageTypes( @@ -391,7 +391,7 @@ func newDistro(name string, minor int) *distribution { ImageFormat: platform.FORMAT_RAW, }, }, - mkAMIImgTypeAarch64(rd.osVersion, rd.isRHEL()), + mkAMIImgTypeAarch64(), ) ppc64le.addImageTypes( @@ -455,7 +455,7 @@ func newDistro(name string, minor int) *distribution { ) // add GCE RHUI image to RHEL only - x86_64.addImageTypes(gceX86Platform, mkGCERHUIImageType(rd.isRHEL())) + x86_64.addImageTypes(gceX86Platform, mkGCERHUIImageType()) } else { x86_64.addImageTypes(azureX64Platform, azureImgType) aarch64.addImageTypes(azureAarch64Platform, azureImgType) diff --git a/pkg/distro/rhel9/gce.go b/pkg/distro/rhel9/gce.go index 8c8c4d3ca2..324d3df747 100644 --- a/pkg/distro/rhel9/gce.go +++ b/pkg/distro/rhel9/gce.go @@ -48,19 +48,21 @@ var ( } ) -func mkGCEImageType(rhsm bool) imageType { +func mkGCEImageType() imageType { it := gceImgType - it.defaultImageConfig = baseGCEImageConfig(rhsm) + // The configuration for non-RHUI images does not touch the RHSM configuration at all. + // https://issues.redhat.com/browse/COMPOSER-2157 + it.defaultImageConfig = baseGCEImageConfig() return it } -func mkGCERHUIImageType(rhsm bool) imageType { +func mkGCERHUIImageType() imageType { it := gceRhuiImgType - it.defaultImageConfig = defaultGceRhuiImageConfig(rhsm) + it.defaultImageConfig = defaultGceRhuiImageConfig() return it } -func baseGCEImageConfig(rhsm bool) *distro.ImageConfig { +func baseGCEImageConfig() *distro.ImageConfig { ic := &distro.ImageConfig{ Timezone: common.ToPtr("UTC"), TimeSynchronization: &osbuild.ChronyStageOptions{ @@ -154,37 +156,10 @@ func baseGCEImageConfig(rhsm bool) *distro.ImageConfig { }, } - if rhsm { - ic.RHSMConfig = map[subscription.RHSMStatus]*osbuild.RHSMStageOptions{ - subscription.RHSMConfigNoSubscription: { - SubMan: &osbuild.RHSMStageOptionsSubMan{ - Rhsmcertd: &osbuild.SubManConfigRHSMCERTDSection{ - AutoRegistration: common.ToPtr(true), - }, - // Don't disable RHSM redhat.repo management on the GCE - // image, which is BYOS and does not use RHUI for content. - // Otherwise subscribing the system manually after booting - // it would result in empty redhat.repo. Without RHUI, such - // system would have no way to get Red Hat content, but - // enable the repo management manually, which would be very - // confusing. - }, - }, - subscription.RHSMConfigWithSubscription: { - SubMan: &osbuild.RHSMStageOptionsSubMan{ - Rhsmcertd: &osbuild.SubManConfigRHSMCERTDSection{ - AutoRegistration: common.ToPtr(true), - }, - // do not disable the redhat.repo management if the user - // explicitly request the system to be subscribed - }, - }, - } - } return ic } -func defaultGceRhuiImageConfig(rhsm bool) *distro.ImageConfig { +func defaultGceRhuiImageConfig() *distro.ImageConfig { ic := &distro.ImageConfig{ RHSMConfig: map[subscription.RHSMStatus]*osbuild.RHSMStageOptions{ subscription.RHSMConfigNoSubscription: { @@ -208,7 +183,7 @@ func defaultGceRhuiImageConfig(rhsm bool) *distro.ImageConfig { }, }, } - return ic.InheritFrom(baseGCEImageConfig(rhsm)) + return ic.InheritFrom(baseGCEImageConfig()) } func gceCommonPackageSet(t *imageType) rpmmd.PackageSet {