From 985dbcfeecde49c86ef854e6d9618a0c734e64ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Thu, 15 Jul 2021 10:50:35 +0200 Subject: [PATCH] distro/rhel85: handle subscriptions only once in the pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the first boot stage was added twice if the subscription customization was enabled. This doesn't work because the first boot stage cannot be specified twice in one pipeline. Also, it didn't make much sense because it just duplicated the effort so I just removed one of the two stages. Signed-off-by: Ondřej Budai --- internal/distro/rhel85/pipelines.go | 70 +++-------------------------- 1 file changed, 5 insertions(+), 65 deletions(-) diff --git a/internal/distro/rhel85/pipelines.go b/internal/distro/rhel85/pipelines.go index f31af1243..47530f7e7 100644 --- a/internal/distro/rhel85/pipelines.go +++ b/internal/distro/rhel85/pipelines.go @@ -20,20 +20,8 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti if err != nil { return nil, err } - if options.Subscription != nil { - commands := []string{ - fmt.Sprintf("/usr/sbin/subscription-manager register --org=%d --activationkey=%s --serverurl %s --baseurl %s", options.Subscription.Organization, options.Subscription.ActivationKey, options.Subscription.ServerUrl, options.Subscription.BaseUrl), - } - if options.Subscription.Insights { - commands = append(commands, "/usr/bin/insights-client --register") - } - treePipeline.AddStage(osbuild.NewFirstBootStage(&osbuild.FirstBootStageOptions{ - Commands: commands, - WaitForNetwork: true, - }, - )) - } else { + if options.Subscription == nil { // RHSM DNF plugins should be by default disabled on RHEL Guest KVM images treePipeline.AddStage(osbuild.NewRHSMStage(&osbuild.RHSMStageOptions{ DnfPlugins: &osbuild.RHSMStageOptionsDnfPlugins{ @@ -68,19 +56,7 @@ func vhdPipelines(t *imageType, customizations *blueprint.Customizations, option if err != nil { return nil, err } - if options.Subscription != nil { - commands := []string{ - fmt.Sprintf("/usr/sbin/subscription-manager register --org=%d --activationkey=%s --serverurl %s --baseurl %s", options.Subscription.Organization, options.Subscription.ActivationKey, options.Subscription.ServerUrl, options.Subscription.BaseUrl), - } - if options.Subscription.Insights { - commands = append(commands, "/usr/bin/insights-client --register") - } - treePipeline.AddStage(osbuild.NewFirstBootStage(&osbuild.FirstBootStageOptions{ - Commands: commands, - WaitForNetwork: true, - }, - )) - } + partitionTable := defaultPartitionTable(options, t.arch, rng) treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2())) treePipeline.AddStage(osbuild.NewGRUB2Stage(grub2StageOptions(&partitionTable, t.kernelOptions, customizations.GetKernel(), packageSetSpecs["packages"], t.arch.uefi, t.arch.legacy))) @@ -105,19 +81,7 @@ func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, optio if err != nil { return nil, err } - if options.Subscription != nil { - commands := []string{ - fmt.Sprintf("/usr/sbin/subscription-manager register --org=%d --activationkey=%s --serverurl %s --baseurl %s", options.Subscription.Organization, options.Subscription.ActivationKey, options.Subscription.ServerUrl, options.Subscription.BaseUrl), - } - if options.Subscription.Insights { - commands = append(commands, "/usr/bin/insights-client --register") - } - treePipeline.AddStage(osbuild.NewFirstBootStage(&osbuild.FirstBootStageOptions{ - Commands: commands, - WaitForNetwork: true, - }, - )) - } + partitionTable := defaultPartitionTable(options, t.arch, rng) treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2())) treePipeline.AddStage(osbuild.NewGRUB2Stage(grub2StageOptions(&partitionTable, t.kernelOptions, customizations.GetKernel(), packageSetSpecs["packages"], t.arch.uefi, t.arch.legacy))) @@ -142,19 +106,7 @@ func openstackPipelines(t *imageType, customizations *blueprint.Customizations, if err != nil { return nil, err } - if options.Subscription != nil { - commands := []string{ - fmt.Sprintf("/usr/sbin/subscription-manager register --org=%d --activationkey=%s --serverurl %s --baseurl %s", options.Subscription.Organization, options.Subscription.ActivationKey, options.Subscription.ServerUrl, options.Subscription.BaseUrl), - } - if options.Subscription.Insights { - commands = append(commands, "/usr/bin/insights-client --register") - } - treePipeline.AddStage(osbuild.NewFirstBootStage(&osbuild.FirstBootStageOptions{ - Commands: commands, - WaitForNetwork: true, - }, - )) - } + partitionTable := defaultPartitionTable(options, t.arch, rng) treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2())) treePipeline.AddStage(osbuild.NewGRUB2Stage(grub2StageOptions(&partitionTable, t.kernelOptions, customizations.GetKernel(), packageSetSpecs["packages"], t.arch.uefi, t.arch.legacy))) @@ -179,19 +131,7 @@ func amiPipelines(t *imageType, customizations *blueprint.Customizations, option if err != nil { return nil, err } - if options.Subscription != nil { - commands := []string{ - fmt.Sprintf("/usr/sbin/subscription-manager register --org=%d --activationkey=%s --serverurl %s --baseurl %s", options.Subscription.Organization, options.Subscription.ActivationKey, options.Subscription.ServerUrl, options.Subscription.BaseUrl), - } - if options.Subscription.Insights { - commands = append(commands, "/usr/bin/insights-client --register") - } - treePipeline.AddStage(osbuild.NewFirstBootStage(&osbuild.FirstBootStageOptions{ - Commands: commands, - WaitForNetwork: true, - }, - )) - } + partitionTable := defaultPartitionTable(options, t.arch, rng) treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2())) treePipeline.AddStage(osbuild.NewGRUB2Stage(grub2StageOptions(&partitionTable, t.kernelOptions, customizations.GetKernel(), packageSetSpecs["packages"], t.arch.uefi, t.arch.legacy)))