Skip to content

Commit

Permalink
support ignition in edge simplified-installer and raw-image
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Murdaca <[email protected]>
Signed-off-by: Antonio Murdaca <[email protected]>
Signed-off-by: Irene Diez <[email protected]>
Co-authored-by: Irene Diez <[email protected]>
Signed-off-by: Antonio Murdaca <[email protected]>
  • Loading branch information
runcom and 7flying committed Jan 11, 2023
1 parent f26e684 commit 6a799e1
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 18 deletions.
4 changes: 4 additions & 0 deletions internal/distro/rhel9/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ func edgeCommitPackageSet(t *imageType) rpmmd.PackageSet {
ps = ps.Append(aarch64EdgeCommitPackageSet(t))
}

if !common.VersionLessThan(t.arch.distro.osVersion, "9.2") || !common.VersionLessThan(t.arch.distro.osVersion, "9-stream") {
ps.Include = append(ps.Include, "ignition", "ignition-edge", "ssh-key-dir")
}

return ps

}
Expand Down
5 changes: 5 additions & 0 deletions internal/distro/rhel9/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/rand"

"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/container"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/fdo"
Expand Down Expand Up @@ -243,6 +244,9 @@ func edgeContainerImage(workload workload.Workload,

img.Platform = t.platform
img.OSCustomizations = osCustomizations(t, packageSets[osPkgsKey], options, containers, customizations)
if !common.VersionLessThan(t.arch.distro.osVersion, "9.2") || !common.VersionLessThan(t.arch.distro.osVersion, "9-stream") {
img.OSCustomizations.EnabledServices = append(img.OSCustomizations.EnabledServices, "ignition-firstboot-complete.service", "coreos-ignition-write-issues", "coreos-ignition-write-issues")
}
img.ContainerLanguage = img.OSCustomizations.Language
img.Environment = t.environment
img.Workload = workload
Expand Down Expand Up @@ -375,6 +379,7 @@ func edgeSimplifiedInstallerImage(workload workload.Workload,
Checksum: options.OSTree.FetchChecksum,
}
rawImg := image.NewOSTreeRawImage(commit)
rawImg.Ignition = true

rawImg.Users = users.UsersFromBP(customizations.GetUsers())
rawImg.Groups = users.GroupsFromBP(customizations.GetGroups())
Expand Down
4 changes: 3 additions & 1 deletion internal/image/ostree_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type OSTreeRawImage struct {
Locale string

Filename string

Ignition bool
}

func NewOSTreeRawImage(commit ostree.CommitSpec) *OSTreeRawImage {
Expand All @@ -46,7 +48,7 @@ func NewOSTreeRawImage(commit ostree.CommitSpec) *OSTreeRawImage {
}

func ostreeCompressedImagePipelines(img *OSTreeRawImage, m *manifest.Manifest, buildPipeline *manifest.Build) *manifest.XZ {
osPipeline := manifest.NewOSTreeDeployment(m, buildPipeline, img.Commit, img.OSName, img.Platform)
osPipeline := manifest.NewOSTreeDeployment(m, buildPipeline, img.Commit, img.OSName, img.Ignition, img.Platform)
osPipeline.PartitionTable = img.PartitionTable
osPipeline.Remote = img.Remote
osPipeline.KernelOptionsAppend = img.KernelOptionsAppend
Expand Down
18 changes: 18 additions & 0 deletions internal/manifest/commit_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type OSTreeDeployment struct {
platform platform.Platform

PartitionTable *disk.PartitionTable

// Whether ignition is in use or not
ignition bool
}

// NewOSTreeDeployment creates a pipeline for an ostree deployment from a
Expand All @@ -45,13 +48,15 @@ func NewOSTreeDeployment(m *Manifest,
buildPipeline *Build,
commit ostree.CommitSpec,
osName string,
ignition bool,
platform platform.Platform) *OSTreeDeployment {

p := &OSTreeDeployment{
Base: NewBase(m, "image-tree", buildPipeline),
commit: commit,
osName: osName,
platform: platform,
ignition: ignition,
}
buildPipeline.addDependent(p)
m.addPipeline(p)
Expand Down Expand Up @@ -95,6 +100,14 @@ func (p *OSTreeDeployment) serialize() osbuild.Pipeline {
kernelOpts := osbuild.GenImageKernelOptions(p.PartitionTable)
kernelOpts = append(kernelOpts, p.KernelOptionsAppend...)

if p.ignition {
kernelOpts = append(kernelOpts,
"coreos.no_persist_ip", // users cannot add connections as we don't have a live iso, this prevents connections to bleed into the system from the ign initrd
"ignition.platform.id=metal",
"$ignition_firstboot",
)
}

pipeline.AddStage(osbuild.NewOSTreeDeployStage(
&osbuild.OSTreeDeployStageOptions{
OsName: p.osName,
Expand Down Expand Up @@ -170,6 +183,10 @@ func (p *OSTreeDeployment) serialize() osbuild.Pipeline {
pipeline.AddStage(grpStage)
}

if p.ignition {
pipeline.AddStage(osbuild.NewIgnitionStage(&osbuild.IgnitionStageOptions{}))
}

// if no root password is set, lock the root account
hasRoot := false
for _, user := range p.Users {
Expand Down Expand Up @@ -216,6 +233,7 @@ func (p *OSTreeDeployment) serialize() osbuild.Pipeline {
p.platform.GetBIOSPlatform(),
p.platform.GetUEFIVendor(), true)
grubOptions.Greenboot = true
grubOptions.Ignition = p.ignition
grubOptions.Config = &osbuild.GRUB2Config{
Default: "saved",
Timeout: 1,
Expand Down
1 change: 1 addition & 0 deletions internal/osbuild/grub2_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type GRUB2StageOptions struct {
Greenboot bool `json:"greenboot,omitempty"`
WriteCmdLine *bool `json:"write_cmdline,omitempty"`
Config *GRUB2Config `json:"config,omitempty"`
Ignition bool `json:"ignition,omitempty"`
}

type GRUB2UEFI struct {
Expand Down
12 changes: 12 additions & 0 deletions internal/osbuild/ignition_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ import (
"fmt"
)

type IgnitionStageOptions struct {
}

func (IgnitionStageOptions) isStageOptions() {}

func NewIgnitionStage(options *IgnitionStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.ignition",
Options: options,
}
}

type IgnitionStageInputInline struct {
InlineFile IgnitionStageInput `json:"inlinefile"`
}
Expand Down
Loading

0 comments on commit 6a799e1

Please sign in to comment.