From e8d40b4083ec730e0ea7ceb66603680ef32c5206 Mon Sep 17 00:00:00 2001 From: Jonathan Holloway Date: Tue, 4 Feb 2025 15:42:16 -0600 Subject: [PATCH] manifest: add insights-client.service enable Signed-off-by: Jonathan Holloway --- pkg/manifest/anaconda_installer_iso_tree.go | 16 +++++++++++++++- pkg/manifest/anaconda_installer_iso_tree_test.go | 9 +++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/pkg/manifest/anaconda_installer_iso_tree.go b/pkg/manifest/anaconda_installer_iso_tree.go index 6d31caf33c..98ed731990 100644 --- a/pkg/manifest/anaconda_installer_iso_tree.go +++ b/pkg/manifest/anaconda_installer_iso_tree.go @@ -702,7 +702,9 @@ func (p *AnacondaInstallerISOTree) makeKickstartStages(stageOptions *osbuild.Kic } hardcodedKickstartBits += makeKickstartSubscriptionPost(subscriptionPath, systemPath) - + if p.SubscriptionPipeline.Subscription != nil && p.SubscriptionPipeline.Subscription.Insights { + hardcodedKickstartBits += makeKickstartInsightsClientBootPost() + } // include a readme file on the ISO in the subscription path to explain what it's for subscriptionReadme, err := fsnode.NewFile( filepath.Join(subscriptionPath, "README"), @@ -780,3 +782,15 @@ systemctl enable osbuild-subscription-register.service ` return fmt.Sprintf(kickstartSubscriptionPost, fullSourcePath, dest) } + +func makeKickstartInsightsClientBootPost() string { + // Enabling the insights-client.service is necessary for the insights client to + // collect when a system is rebooted after an upgrade. + // It is facilitated via insights-client.service.d/override.conf + kickstartInsightsClientBootPost := ` +%post +systemctl enable insights-client.service +%end +` + return kickstartInsightsClientBootPost +} diff --git a/pkg/manifest/anaconda_installer_iso_tree_test.go b/pkg/manifest/anaconda_installer_iso_tree_test.go index 9f8c5649e4..8332c53940 100644 --- a/pkg/manifest/anaconda_installer_iso_tree_test.go +++ b/pkg/manifest/anaconda_installer_iso_tree_test.go @@ -768,3 +768,12 @@ func TestPayloadRemoveSignatures(t *testing.T) { assert.Equal(t, tc.expected, skopeoStage.Options.(*osbuild.SkopeoStageOptions).RemoveSignatures) } } + +func TestMakeKickstartInsightsClientBootPost(t *testing.T) { + exp := ` +%post +systemctl enable insights-client.service +%end +` + assert.Equal(t, exp, makeKickstartInsightsClientBootPost()) +}