Skip to content

Commit

Permalink
RHEL-8: don't touch rhsm.conf on non-RHUI images.
Browse files Browse the repository at this point in the history
Previously, the auto-registration was explicitly enabled in rhsm.conf
even for non-RHUI cloud images. These are the images that users can
build on-prem or in the hosted service (as vanilla or as customized).
However, the feature never really worked for these images.

Stop enabling the auto-registration in rhsm.conf (basically stop
touching the configuration at all).

Related to https://issues.redhat.com/browse/COMPOSER-2157

Signed-off-by: Tomáš Hozza <[email protected]>
  • Loading branch information
thozza committed Feb 22, 2024
1 parent 2dd0d04 commit a438e7d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 68 deletions.
30 changes: 14 additions & 16 deletions pkg/distro/rhel8/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func amiImgTypeX86_64(rd distribution) imageType {
packageSets: map[string]packageSetFunc{
osPkgsKey: ec2CommonPackageSet,
},
defaultImageConfig: defaultAMIImageConfigX86_64(rd),
defaultImageConfig: defaultAMIImageConfigX86_64(),
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
bootable: true,
defaultSize: 10 * common.GibiByte,
Expand Down Expand Up @@ -82,7 +82,7 @@ func amiImgTypeAarch64(rd distribution) imageType {
packageSets: map[string]packageSetFunc{
osPkgsKey: ec2CommonPackageSet,
},
defaultImageConfig: defaultAMIImageConfig(rd),
defaultImageConfig: defaultAMIImageConfig(),
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
bootable: true,
defaultSize: 10 * common.GibiByte,
Expand Down Expand Up @@ -203,7 +203,6 @@ func baseEc2ImageConfig() *distro.ImageConfig {
{
Filename: "00-getty-fixes.conf",
Config: osbuild.SystemdLogindConfigDropin{

Login: osbuild.SystemdLogindConfigLoginSection{
NAutoVTs: common.ToPtr(0),
},
Expand Down Expand Up @@ -283,24 +282,23 @@ func defaultEc2ImageConfig(rd distribution) *distro.ImageConfig {
return ic
}

// default AMI (EC2 BYOS) images config
func defaultAMIImageConfig(rd distribution) *distro.ImageConfig {
ic := defaultEc2ImageConfig(rd)
if rd.isRHEL() {
// defaultEc2ImageConfig() adds the rhsm options only for RHEL < 8.7
// Add it unconditionally for AMI
ic = appendRHSM(ic)
}
return ic
}

func defaultEc2ImageConfigX86_64(rd distribution) *distro.ImageConfig {
ic := defaultEc2ImageConfig(rd)
return appendEC2DracutX86_64(ic)
}

func defaultAMIImageConfigX86_64(rd distribution) *distro.ImageConfig {
ic := defaultAMIImageConfig(rd).InheritFrom(defaultEc2ImageConfigX86_64(rd))
// 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)
}

Expand Down
27 changes: 2 additions & 25 deletions pkg/distro/rhel8/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,35 +629,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`
Expand Down
29 changes: 2 additions & 27 deletions pkg/distro/rhel8/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func gceRhuiImgType(rd distribution) imageType {
}
}

// The configuration for non-RHUI images does not touch the RHSM configuration at all.
// https://issues.redhat.com/browse/COMPOSER-2157
func defaultGceByosImageConfig(rd distribution) *distro.ImageConfig {
ic := &distro.ImageConfig{
Timezone: common.ToPtr("UTC"),
Expand Down Expand Up @@ -156,33 +158,6 @@ func defaultGceByosImageConfig(rd distribution) *distro.ImageConfig {
)
}

if rd.isRHEL() {
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
}

Expand Down

0 comments on commit a438e7d

Please sign in to comment.