diff --git a/internal/app/wwctl/overlay/build/main.go b/internal/app/wwctl/overlay/build/main.go index eaeeaac7..9648664e 100644 --- a/internal/app/wwctl/overlay/build/main.go +++ b/internal/app/wwctl/overlay/build/main.go @@ -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) + } } diff --git a/internal/app/wwctl/overlay/build/root.go b/internal/app/wwctl/overlay/build/root.go index e8ad090e..8560670f 100644 --- a/internal/app/wwctl/overlay/build/root.go +++ b/internal/app/wwctl/overlay/build/root.go @@ -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.`) } diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index f6ed7658..94b50b85 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -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*"))