Skip to content

Commit

Permalink
fix(fedora-iot-raw): enable ignition-firstboot-complete.service
Browse files Browse the repository at this point in the history
enabling this service by default so that /boot/ignition.firstboot file is removed on first boot successfully.

Signed-off-by: Sarita Mahajan <[email protected]>
  • Loading branch information
sarmahaj committed Feb 19, 2025
1 parent 201158b commit 85e38ae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions pkg/distro/fedora/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ var (
OSTreeConfSysrootReadOnly: common.ToPtr(true),
LockRootUser: common.ToPtr(true),
IgnitionPlatform: common.ToPtr("metal"),
EnabledServices: []string{"ignition-firstboot-complete.service"},
},
defaultSize: 4 * datasizes.GibiByte,
rpmOstree: true,
Expand Down
3 changes: 3 additions & 0 deletions pkg/distro/fedora/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ func ostreeDeploymentCustomizations(
deploymentConf.CustomFileSystems = append(deploymentConf.CustomFileSystems, fs.Mountpoint)
}

deploymentConf.EnabledServices = imageConfig.EnabledServices
deploymentConf.DisabledServices = imageConfig.DisabledServices

return deploymentConf, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/image/ostree_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func baseRawOstreeImage(img *OSTreeDiskImage, buildPipeline manifest.Build, opts

// other image types (e.g. live) pass the workload to the pipeline.
if img.Workload != nil {
osPipeline.EnabledServices = img.Workload.GetServices()
osPipeline.DisabledServices = img.Workload.GetDisabledServices()
osPipeline.OSTreeDeploymentCustomizations.EnabledServices = append(osPipeline.OSTreeDeploymentCustomizations.EnabledServices, img.Workload.GetServices()...)
osPipeline.OSTreeDeploymentCustomizations.DisabledServices = append(osPipeline.OSTreeDeploymentCustomizations.DisabledServices, img.Workload.GetDisabledServices()...)
}
return manifest.NewRawOStreeImage(buildPipeline, osPipeline, img.Platform)
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/manifest/ostree_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type OSTreeDeploymentCustomizations struct {
// Lock the root account in the deployment unless the user defined root
// user options in the build configuration.
LockRoot bool

EnabledServices []string
DisabledServices []string
}

// OSTreeDeployment represents the filesystem tree of a target image based
Expand Down Expand Up @@ -78,9 +81,6 @@ type OSTreeDeployment struct {

PartitionTable *disk.PartitionTable

EnabledServices []string
DisabledServices []string

// Use bootupd instead of grub2 as the bootloader
UseBootupd bool
}
Expand Down Expand Up @@ -375,7 +375,7 @@ func (p *OSTreeDeployment) serialize() osbuild.Pipeline {
stageOption := osbuild.NewSystemdUnitCreateStage(createMountpointService(serviceName, p.CustomFileSystems))
stageOption.MountOSTree(p.osName, ref, 0)
pipeline.AddStage(stageOption)
p.EnabledServices = append(p.EnabledServices, serviceName)
p.OSTreeDeploymentCustomizations.EnabledServices = append(p.OSTreeDeploymentCustomizations.EnabledServices, serviceName)
}

// We enable / disable services below using the systemd stage, but its effect
Expand All @@ -384,8 +384,8 @@ func (p *OSTreeDeployment) serialize() osbuild.Pipeline {
// only when Ignition is used. To prevent this and to not have a special cases
// in the code based on distro version, we enable / disable services also by
// creating a preset file.
if len(p.EnabledServices) != 0 || len(p.DisabledServices) != 0 {
presetsStage := osbuild.GenServicesPresetStage(p.EnabledServices, p.DisabledServices)
if len(p.OSTreeDeploymentCustomizations.EnabledServices) != 0 || len(p.OSTreeDeploymentCustomizations.DisabledServices) != 0 {
presetsStage := osbuild.GenServicesPresetStage(p.OSTreeDeploymentCustomizations.EnabledServices, p.OSTreeDeploymentCustomizations.DisabledServices)
presetsStage.MountOSTree(p.osName, ref, 0)
pipeline.AddStage(presetsStage)
}
Expand Down Expand Up @@ -475,10 +475,10 @@ func (p *OSTreeDeployment) serialize() osbuild.Pipeline {
pipeline.AddStages(fileStages...)
}

if len(p.EnabledServices) != 0 || len(p.DisabledServices) != 0 {
if len(p.OSTreeDeploymentCustomizations.EnabledServices) != 0 || len(p.OSTreeDeploymentCustomizations.DisabledServices) != 0 {
systemdStage := osbuild.NewSystemdStage(&osbuild.SystemdStageOptions{
EnabledServices: p.EnabledServices,
DisabledServices: p.DisabledServices,
EnabledServices: p.OSTreeDeploymentCustomizations.EnabledServices,
DisabledServices: p.OSTreeDeploymentCustomizations.DisabledServices,
})
systemdStage.MountOSTree(p.osName, ref, 0)
pipeline.AddStage(systemdStage)
Expand Down

0 comments on commit 85e38ae

Please sign in to comment.