Skip to content

Commit

Permalink
distro: add a kickstart file to /root for minimal-raw images
Browse files Browse the repository at this point in the history
Currently initial-setup requires a kickstart file in the /root directory
to work.  Adding a temporary file node to the image config for
minimal-raw images so that initial-setup runs and a user can be created
if necessary.  The minimal-raw image has no other mechanism for creating
a user if one wasn't specified at build time, so we need to be sure that
initial-setup runs.
  • Loading branch information
achilleas-k committed Sep 15, 2023
1 parent 049c97b commit 51f73a6
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/distro/fedora/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/osbuild/images/internal/common"
"github.com/osbuild/images/internal/environment"
"github.com/osbuild/images/internal/fsnode"
"github.com/osbuild/images/internal/oscap"
"github.com/osbuild/images/pkg/distro"
"github.com/osbuild/images/pkg/osbuild"
Expand Down Expand Up @@ -387,6 +388,9 @@ var (
},
defaultImageConfig: &distro.ImageConfig{
EnabledServices: minimalRawServices,
// NOTE: temporary workaround for a bug in initial-setup that
// requires a kickstart file in the root directory.
Files: []*fsnode.File{initialSetupKickstart()},
},
rpmOstree: false,
kernelOptions: defaultKernelOptions,
Expand Down
11 changes: 11 additions & 0 deletions pkg/distro/fedora/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/osbuild/images/internal/common"
"github.com/osbuild/images/internal/fdo"
"github.com/osbuild/images/internal/fsnode"
"github.com/osbuild/images/internal/ignition"
"github.com/osbuild/images/internal/oscap"
"github.com/osbuild/images/internal/users"
Expand Down Expand Up @@ -687,3 +688,13 @@ func makeOSTreePayloadCommit(options *ostree.ImageOptions, defaultRef string) (o
RHSM: options.RHSM,
}, nil
}

// initialSetupKickstart returns the File configuration for a kickstart file
// that's required to enable initial-setup to run on first boot.
func initialSetupKickstart() *fsnode.File {
file, err := fsnode.NewFile("/root/anaconda-ks.cfg", nil, "root", "root", []byte("# Run initial-setup on first boot\n# Created by osbuild\nfirstboot --reconfig\n"))
if err != nil {
panic(err)
}
return file
}
4 changes: 4 additions & 0 deletions pkg/distro/rhel8/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/osbuild/images/internal/common"
"github.com/osbuild/images/internal/fsnode"
"github.com/osbuild/images/pkg/distro"
"github.com/osbuild/images/pkg/platform"
"github.com/osbuild/images/pkg/rpmmd"
Expand Down Expand Up @@ -150,6 +151,9 @@ func minimalRawImgType(rd distribution) imageType {
},
defaultImageConfig: &distro.ImageConfig{
EnabledServices: minimalrawServices(rd),
// NOTE: temporary workaround for a bug in initial-setup that
// requires a kickstart file in the root directory.
Files: []*fsnode.File{initialSetupKickstart()},
},
rpmOstree: false,
kernelOptions: "ro",
Expand Down
11 changes: 11 additions & 0 deletions pkg/distro/rhel8/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/rand"

"github.com/osbuild/images/internal/fdo"
"github.com/osbuild/images/internal/fsnode"
"github.com/osbuild/images/internal/ignition"
"github.com/osbuild/images/internal/oscap"
"github.com/osbuild/images/internal/users"
Expand Down Expand Up @@ -602,3 +603,13 @@ func makeOSTreePayloadCommit(options *ostree.ImageOptions, defaultRef string) (o
RHSM: options.RHSM,
}, nil
}

// initialSetupKickstart returns the File configuration for a kickstart file
// that's required to enable initial-setup to run on first boot.
func initialSetupKickstart() *fsnode.File {
file, err := fsnode.NewFile("/root/anaconda-ks.cfg", nil, "root", "root", []byte("# Run initial-setup on first boot\n# Created by osbuild\nfirstboot --reconfig\nlang en_US.UTF-8\n"))
if err != nil {
panic(err)
}
return file
}
4 changes: 4 additions & 0 deletions pkg/distro/rhel9/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/osbuild/images/internal/common"
"github.com/osbuild/images/internal/environment"
"github.com/osbuild/images/internal/fsnode"
"github.com/osbuild/images/pkg/disk"
"github.com/osbuild/images/pkg/distro"
"github.com/osbuild/images/pkg/osbuild"
Expand Down Expand Up @@ -186,6 +187,9 @@ var (
defaultImageConfig: &distro.ImageConfig{
EnabledServices: minimalrawServices,
SystemdUnit: systemdUnits,
// NOTE: temporary workaround for a bug in initial-setup that
// requires a kickstart file in the root directory.
Files: []*fsnode.File{initialSetupKickstart()},
},
rpmOstree: false,
kernelOptions: "ro",
Expand Down
11 changes: 11 additions & 0 deletions pkg/distro/rhel9/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/osbuild/images/internal/common"
"github.com/osbuild/images/internal/fdo"
"github.com/osbuild/images/internal/fsnode"
"github.com/osbuild/images/internal/ignition"
"github.com/osbuild/images/internal/oscap"
"github.com/osbuild/images/internal/users"
Expand Down Expand Up @@ -650,3 +651,13 @@ func makeOSTreePayloadCommit(options *ostree.ImageOptions, defaultRef string) (o
RHSM: options.RHSM,
}, nil
}

// initialSetupKickstart returns the File configuration for a kickstart file
// that's required to enable initial-setup to run on first boot.
func initialSetupKickstart() *fsnode.File {
file, err := fsnode.NewFile("/root/anaconda-ks.cfg", nil, "root", "root", []byte("# Run initial-setup on first boot\n# Created by osbuild\nfirstboot --reconfig\nlang en_US.UTF-8\n"))
if err != nil {
panic(err)
}
return file
}

0 comments on commit 51f73a6

Please sign in to comment.