Refactor ignition support during dracut
- Control root device using the node/profile root field - Add support for `/warewulf/wwinit.d` to run scripts during first stage - Move first-stage ignition support to `/warewulf/wwinit.d/` - Add `wwctl <node|profile> set --parttype` - Add overlay template functions `SystemdEscape` and `SystemdEscapePath` - Support configuring ignition with resources Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
|
||||
"github.com/warewulf/warewulf/internal/pkg/image"
|
||||
"github.com/warewulf/warewulf/internal/pkg/kernel"
|
||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
||||
)
|
||||
@@ -39,7 +38,6 @@ type TemplateStruct struct {
|
||||
Tftp warewulfconf.TFTPConf
|
||||
Paths warewulfconf.BuildConfig
|
||||
AllNodes []node.Node
|
||||
ImageList []string
|
||||
node.Node
|
||||
// backward compatiblity
|
||||
Container string
|
||||
@@ -50,7 +48,8 @@ type TemplateStruct struct {
|
||||
/*
|
||||
Initialize an TemplateStruct with the given node.NodeInfo
|
||||
*/
|
||||
func InitStruct(overlayName string, nodeData node.Node, allNodes []node.Node) (tstruct TemplateStruct, err error) {
|
||||
func InitStruct(overlayName string, nodeData node.Node, allNodes []node.Node) (TemplateStruct, error) {
|
||||
var tstruct TemplateStruct
|
||||
tstruct.Overlay = overlayName
|
||||
hostname, _ := os.Hostname()
|
||||
tstruct.BuildHost = hostname
|
||||
@@ -77,10 +76,6 @@ func InitStruct(overlayName string, nodeData node.Node, allNodes []node.Node) (t
|
||||
// init some convenience vars
|
||||
tstruct.Id = nodeData.Id()
|
||||
tstruct.Hostname = nodeData.Id()
|
||||
tstruct.ImageList, err = image.ListSources()
|
||||
if err != nil {
|
||||
return tstruct, err
|
||||
}
|
||||
tstruct.Container = nodeData.ImageName
|
||||
tstruct.ContainerName = nodeData.ImageName
|
||||
// Backwards compatibility for templates using "Keys"
|
||||
|
||||
@@ -102,7 +102,7 @@ func templateImageFileInclude(imagename string, filepath string) string {
|
||||
// Don't return an error as we use this function for template evaluation, so
|
||||
// error will turn up there as the return string
|
||||
func createIgnitionJson(node *node.Node) string {
|
||||
conf, rep, err := node.GetConfig()
|
||||
conf, rep, err := node.GetIgnitionConfig()
|
||||
if len(conf.Storage.Disks) == 0 && len(conf.Storage.Filesystems) == 0 {
|
||||
wwlog.Debug("no disks or filesystems present, don't create a json object")
|
||||
return ""
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"text/template"
|
||||
|
||||
"github.com/Masterminds/sprig/v3"
|
||||
"github.com/coreos/go-systemd/v22/unit"
|
||||
|
||||
"github.com/warewulf/warewulf/internal/pkg/config"
|
||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
||||
@@ -496,12 +497,7 @@ func RenderTemplateFile(fileName string, data TemplateStruct) (
|
||||
"softlink": softlink,
|
||||
"readlink": filepath.EvalSymlinks,
|
||||
"IgnitionJson": func() string {
|
||||
str := createIgnitionJson(data.ThisNode)
|
||||
if str != "" {
|
||||
return str
|
||||
}
|
||||
writeFile = false
|
||||
return ""
|
||||
return createIgnitionJson(data.ThisNode)
|
||||
},
|
||||
"abort": func() string {
|
||||
wwlog.Debug("abort file called in %s", fileName)
|
||||
@@ -513,7 +509,9 @@ func RenderTemplateFile(fileName string, data TemplateStruct) (
|
||||
backupFile = false
|
||||
return ""
|
||||
},
|
||||
"UniqueField": UniqueField,
|
||||
"UniqueField": UniqueField,
|
||||
"SystemdEscape": unit.UnitNameEscape,
|
||||
"SystemdEscapePath": unit.UnitNamePathEscape,
|
||||
}
|
||||
|
||||
// Merge sprig.FuncMap with our FuncMap
|
||||
|
||||
Reference in New Issue
Block a user