manifest: support specifying kickstart file location
Add support for specifying where the kickstart file will be created:
either in the default location in the anaconda tree or at the root of
the ISO like we did so far in RHEL.
From the distro level, this is controlled by a boolean that when set to
true puts the kickstart file in the root of the ISO tree at /osbuild.ks
(the old behaviour) and if unset falls back to the default location
/usr/share/anaconda/interactive-defaults.ks.
Changed the name of the kickstart file for ostree back to osbuild.ks
Was ostree.ks for a while since a1bfcfe91c.
For Fedora we use the default and for RHEL we maintain the old behaviour
for now.
This commit is contained in:
parent
d4a8775751
commit
c6bfb22f54
4 changed files with 55 additions and 16 deletions
|
|
@ -346,6 +346,9 @@ func imageInstallerImage(workload workload.Workload,
|
|||
|
||||
img.SquashfsCompression = "xz"
|
||||
|
||||
// put the kickstart file in the root of the iso
|
||||
img.ISORootKickstart = true
|
||||
|
||||
d := t.arch.distro
|
||||
|
||||
img.ISOLabelTempl = d.isolabelTmpl
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package image
|
|||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/artifact"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
|
|
@ -16,6 +17,8 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/workload"
|
||||
)
|
||||
|
||||
const kspath = "/osbuild.ks"
|
||||
|
||||
type ImageInstaller struct {
|
||||
Base
|
||||
Platform platform.Platform
|
||||
|
|
@ -27,6 +30,11 @@ type ImageInstaller struct {
|
|||
Users []users.User
|
||||
Groups []users.Group
|
||||
|
||||
// If set, the kickstart file will be added to the bootiso-tree as
|
||||
// /osbuild.ks, otherwise any kickstart options will be configured in the
|
||||
// default /usr/share/anaconda/interactive-defaults.ks in the rootfs.
|
||||
ISORootKickstart bool
|
||||
|
||||
SquashfsCompression string
|
||||
|
||||
ISOLabelTempl string
|
||||
|
|
@ -63,19 +71,21 @@ func (img *ImageInstaller) InstantiateManifest(m *manifest.Manifest,
|
|||
img.Product,
|
||||
img.OSVersion)
|
||||
|
||||
interactiveDefaults := manifest.NewAnacondaInteractiveDefaults(
|
||||
"file:///run/install/repo/liveimg.tar.gz",
|
||||
)
|
||||
|
||||
anacondaPipeline.ExtraPackages = img.ExtraBasePackages.Include
|
||||
anacondaPipeline.ExtraRepos = img.ExtraBasePackages.Repositories
|
||||
anacondaPipeline.Users = img.Users
|
||||
anacondaPipeline.Groups = img.Groups
|
||||
anacondaPipeline.Variant = img.Variant
|
||||
anacondaPipeline.Biosdevname = (img.Platform.GetArch() == platform.ARCH_X86_64)
|
||||
anacondaPipeline.InteractiveDefaults = interactiveDefaults
|
||||
anacondaPipeline.AdditionalModules = img.AdditionalAnacondaModules
|
||||
|
||||
tarPath := "/liveimg.tar.gz"
|
||||
|
||||
if !img.ISORootKickstart {
|
||||
payloadPath := filepath.Join("/run/install/repo/", tarPath)
|
||||
anacondaPipeline.InteractiveDefaults = manifest.NewAnacondaInteractiveDefaults(fmt.Sprintf("file://%s", payloadPath))
|
||||
}
|
||||
|
||||
anacondaPipeline.Checkpoint()
|
||||
|
||||
rootfsPartitionTable := &disk.PartitionTable{
|
||||
|
|
@ -104,6 +114,9 @@ func (img *ImageInstaller) InstantiateManifest(m *manifest.Manifest,
|
|||
bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor()
|
||||
bootTreePipeline.ISOLabel = isoLabel
|
||||
bootTreePipeline.KernelOpts = img.AdditionalKernelOpts
|
||||
if img.ISORootKickstart {
|
||||
bootTreePipeline.KSPath = kspath
|
||||
}
|
||||
|
||||
osPipeline := manifest.NewOS(m, buildPipeline, img.Platform, repos)
|
||||
osPipeline.OSCustomizations = img.OSCustomizations
|
||||
|
|
@ -121,6 +134,10 @@ func (img *ImageInstaller) InstantiateManifest(m *manifest.Manifest,
|
|||
isoTreePipeline.OSName = img.OSName
|
||||
isoTreePipeline.Users = img.Users
|
||||
isoTreePipeline.Groups = img.Groups
|
||||
isoTreePipeline.PayloadPath = tarPath
|
||||
if img.ISORootKickstart {
|
||||
isoTreePipeline.KSPath = kspath
|
||||
}
|
||||
|
||||
isoTreePipeline.SquashfsCompression = img.SquashfsCompression
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ func (img *OSTreeInstaller) InstantiateManifest(m *manifest.Manifest,
|
|||
bootTreePipeline := manifest.NewEFIBootTree(m, buildPipeline, anacondaPipeline)
|
||||
bootTreePipeline.Platform = img.Platform
|
||||
bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor()
|
||||
bootTreePipeline.KSPath = "/ostree.ks"
|
||||
bootTreePipeline.KSPath = kspath
|
||||
bootTreePipeline.ISOLabel = isoLabel
|
||||
|
||||
isoTreePipeline := manifest.NewISOTree(m,
|
||||
|
|
@ -106,7 +106,9 @@ func (img *OSTreeInstaller) InstantiateManifest(m *manifest.Manifest,
|
|||
|
||||
isoTreePipeline.SquashfsCompression = img.SquashfsCompression
|
||||
|
||||
isoTreePipeline.KSPath = "/ostree.ks"
|
||||
// For ostree installers, always put the kickstart file in the root of the ISO
|
||||
isoTreePipeline.KSPath = kspath
|
||||
isoTreePipeline.PayloadPath = "/ostree/repo"
|
||||
|
||||
isoTreePipeline.OSTree = &img.Commit
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,15 @@ type ISOTree struct {
|
|||
rootfsPipeline *ISORootfsImg
|
||||
bootTreePipeline *EFIBootTree
|
||||
|
||||
KSPath string
|
||||
// The location of the kickstart file, if it will be added to the
|
||||
// bootiso-tree.
|
||||
// Otherwise, it should be defined in the interactive defaults of the
|
||||
// Anaconda pipeline.
|
||||
KSPath string
|
||||
|
||||
// The path where the payload (tarball or ostree repo) will be stored.
|
||||
PayloadPath string
|
||||
|
||||
isoLabel string
|
||||
|
||||
SquashfsCompression string
|
||||
|
|
@ -102,7 +110,6 @@ func (p *ISOTree) serialize() osbuild.Pipeline {
|
|||
|
||||
pipeline := p.Base.serialize()
|
||||
|
||||
ostreeRepoPath := "/ostree/repo"
|
||||
kernelOpts := []string{}
|
||||
|
||||
if p.KSPath != "" {
|
||||
|
|
@ -206,13 +213,15 @@ func (p *ISOTree) serialize() osbuild.Pipeline {
|
|||
))
|
||||
|
||||
if p.OSTree != nil {
|
||||
pipeline.AddStage(osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: ostreeRepoPath}))
|
||||
// Set up the payload ostree repo
|
||||
pipeline.AddStage(osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: p.PayloadPath}))
|
||||
pipeline.AddStage(osbuild.NewOSTreePullStage(
|
||||
&osbuild.OSTreePullStageOptions{Repo: ostreeRepoPath},
|
||||
&osbuild.OSTreePullStageOptions{Repo: p.PayloadPath},
|
||||
osbuild.NewOstreePullStageInputs("org.osbuild.source", p.OSTree.Checksum, p.OSTree.Ref),
|
||||
))
|
||||
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(p.KSPath, "", p.Users, p.Groups, makeISORootPath(ostreeRepoPath), p.OSTree.Ref, p.OSName)
|
||||
// Configure the kickstart file with the payload and any user options
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(p.KSPath, "", p.Users, p.Groups, makeISORootPath(p.PayloadPath), p.OSTree.Ref, p.OSName)
|
||||
|
||||
if err != nil {
|
||||
panic("failed to create kickstartstage options")
|
||||
|
|
@ -222,11 +231,19 @@ func (p *ISOTree) serialize() osbuild.Pipeline {
|
|||
}
|
||||
|
||||
if p.OSPipeline != nil {
|
||||
// The TarStage has --autocompress
|
||||
pipeline.AddStage(osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: "/liveimg.tar.gz"}, p.OSPipeline.name))
|
||||
// Create the payload tarball
|
||||
pipeline.AddStage(osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: p.PayloadPath}, p.OSPipeline.name))
|
||||
|
||||
// In the case of OSPipeline then the ImageInstaller has already set InteractiveDefaults on the anaconda-tree,
|
||||
// eliminating the need to set a separate kickstart here.
|
||||
// If the KSPath is set, we need to add the kickstart stage to this (bootiso-tree) pipeline.
|
||||
// If it's not specified here, it should have been added to the InteractiveDefaults in the anaconda-tree.
|
||||
if p.KSPath != "" {
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(p.KSPath, makeISORootPath(p.PayloadPath), p.Users, p.Groups, "", "", p.OSName)
|
||||
if err != nil {
|
||||
panic("failed to create kickstartstage options")
|
||||
}
|
||||
|
||||
pipeline.AddStage(osbuild.NewKickstartStage(kickstartOptions))
|
||||
}
|
||||
}
|
||||
|
||||
pipeline.AddStage(osbuild.NewDiscinfoStage(&osbuild.DiscinfoStageOptions{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue