wwctl overlay buld fixes

This commit is contained in:
Christian Goll
2022-03-16 15:27:50 +01:00
parent 9dbf371174
commit 0d62a26368
3 changed files with 13 additions and 3 deletions

View File

@@ -33,6 +33,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
return overlay.BuildOverlayIndir(node, strings.Split(OverlayName, ","), OverlayDir)
}
} else {
var host node.NodeInfo
var idEntry node.Entry
hostname, _ := os.Hostname()
wwlog.Printf(wwlog.INFO, "Building overlay for %s: host\n", hostname)
idEntry.Set(hostname)
host.Id = idEntry
return overlay.BuildOverlayIndir(host, strings.Split(OverlayName, ","), OverlayDir)
}
}

View File

@@ -20,9 +20,8 @@ func init() {
baseCmd.PersistentFlags().BoolVarP(&BuildHost, "host", "H", false, "Build overlays only for the host")
baseCmd.PersistentFlags().BoolVarP(&BuildNodes, "nodes", "N", false, "Build overlays only for the nodes")
baseCmd.PersistentFlags().StringVarP(&OverlayName, "overlay", "O", "", "Build only specific overlay")
baseCmd.PersistentFlags().StringVarP(&OverlayDir, "output", "o", "", `Do not create an overlay to image, for distribution but write to|
the given directory. An overlay must also be ge given to use this option. '/dev/stdin' will print|
the processed overlay.`)
baseCmd.PersistentFlags().StringVarP(&OverlayDir, "output", "o", "", `Do not create an overlay image, for distribution but write to
the given directory. An overlay must also be ge given to use this option.`)
}

View File

@@ -272,6 +272,7 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir
dt := time.Now()
tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST")
for _, overlayName := range overlayNames {
wwlog.Printf(wwlog.VERBOSE, "Building overlay %s for node %s in %s\n", overlayName, nodeInfo.Id.Get(), outputDir)
overlaySourceDir := OverlaySourceDir(overlayName)
wwlog.Printf(wwlog.DEBUG, "Starting to build overlay %s\nChanging directory to OverlayDir: %s\n", overlayName, overlaySourceDir)
err = os.Chdir(overlaySourceDir)
@@ -319,6 +320,7 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir
"IncludeBlock": templateFileBlock,
"inc": func(i int) int { return i + 1 },
"dec": func(i int) int { return i - 1 },
"file": func(str string) string { return fmt.Sprintf("{{ /* file %s*/ }}", str) },
"abort": func() (string, error) { return "", ErrorAbort },
"nobackup": func() (string, error) { return "", ErrorNoBackup },
// }).ParseGlob(path.Join(OverlayDir, destFile+".ww*"))