make the configuration to be based in warewulf.conf
defaults will be se by the Makefile Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,6 +25,7 @@
|
|||||||
/etc/bash_completion.d/
|
/etc/bash_completion.d/
|
||||||
warewulf.spec
|
warewulf.spec
|
||||||
internal/pkg/buildconfig/setconfigs.go
|
internal/pkg/buildconfig/setconfigs.go
|
||||||
|
internal/pkg/warewulfconf/buildconfig.go
|
||||||
include/systemd/warewulfd.service
|
include/systemd/warewulfd.service
|
||||||
_dist/
|
_dist/
|
||||||
config
|
config
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -231,19 +231,11 @@ man_pages: wwctl
|
|||||||
cp docs/man/man5/*.5 ./man_pages/
|
cp docs/man/man5/*.5 ./man_pages/
|
||||||
cd man_pages; for i in wwctl*1 *.5; do echo "Compressing manpage: $$i"; gzip --force $$i; done
|
cd man_pages; for i in wwctl*1 *.5; do echo "Compressing manpage: $$i"; gzip --force $$i; done
|
||||||
|
|
||||||
config_defaults: vendor cmd/config_defaults/config_defaults.go
|
|
||||||
cd cmd/config_defaults && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=./etc/warewulf.conf'\
|
|
||||||
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf'"\
|
|
||||||
-mod vendor -tags "$(WW_GO_BUILD_TAGS)" -o ../../config_defaults
|
|
||||||
|
|
||||||
update_configuration: vendor cmd/update_configuration/update_configuration.go
|
update_configuration: vendor cmd/update_configuration/update_configuration.go
|
||||||
cd cmd/update_configuration && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=./etc/warewulf.conf'\
|
cd cmd/update_configuration && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=./etc/warewulf.conf'\
|
||||||
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf'"\
|
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf'"\
|
||||||
-mod vendor -tags "$(WW_GO_BUILD_TAGS)" -o ../../update_configuration
|
-mod vendor -tags "$(WW_GO_BUILD_TAGS)" -o ../../update_configuration
|
||||||
|
|
||||||
warewulfconf: config_defaults
|
|
||||||
./config_defaults
|
|
||||||
|
|
||||||
dist: vendor config
|
dist: vendor config
|
||||||
rm -rf .dist/$(WAREWULF)-$(VERSION) $(WAREWULF)-$(VERSION).tar.gz
|
rm -rf .dist/$(WAREWULF)-$(VERSION) $(WAREWULF)-$(VERSION).tar.gz
|
||||||
mkdir -p .dist/$(WAREWULF)-$(VERSION)
|
mkdir -p .dist/$(WAREWULF)-$(VERSION)
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
|
|
||||||
"github.com/coreos/go-systemd/daemon"
|
"github.com/coreos/go-systemd/daemon"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/pidfile"
|
"github.com/hpcng/warewulf/internal/pkg/pidfile"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
@@ -50,10 +49,7 @@ func GetRootCommand() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||||
conf, err := warewulfconf.New()
|
conf := warewulfconf.New()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
pid, err := pidfile.Write(PIDFile)
|
pid, err := pidfile.Write(PIDFile)
|
||||||
if err != nil && pid == -1 {
|
if err != nil && pid == -1 {
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
package buildconfig
|
|
||||||
|
|
||||||
import "github.com/hpcng/warewulf/internal/pkg/wwlog"
|
|
||||||
|
|
||||||
const WWVer = 43
|
|
||||||
|
|
||||||
var (
|
|
||||||
bindir string = "UNDEF"
|
|
||||||
sysconfdir string = "UNDEF"
|
|
||||||
localstatedir string = "UNDEF"
|
|
||||||
srvdir string = "UNDEF"
|
|
||||||
tftpdir string = "UNDEF"
|
|
||||||
firewallddir string = "UNDEF"
|
|
||||||
systemddir string = "UNDEF"
|
|
||||||
wwoverlaydir string = "UNDEF"
|
|
||||||
wwchrootdir string = "UNDEF"
|
|
||||||
wwprovisiondir string = "UNDEF"
|
|
||||||
version string = "UNDEF"
|
|
||||||
release string = "UNDEF"
|
|
||||||
wwclientdir string = "UNDEF"
|
|
||||||
datadir string = "UNDEF"
|
|
||||||
tmpdir string = "UNDEF"
|
|
||||||
)
|
|
||||||
|
|
||||||
func BINDIR() string {
|
|
||||||
wwlog.Debug("BINDIR = '%s'", bindir)
|
|
||||||
return bindir
|
|
||||||
}
|
|
||||||
|
|
||||||
func DATADIR() string {
|
|
||||||
wwlog.Debug("DATADIR = '%s'", datadir)
|
|
||||||
return datadir
|
|
||||||
}
|
|
||||||
|
|
||||||
func SYSCONFDIR() string {
|
|
||||||
wwlog.Debug("SYSCONFDIR = '%s'", sysconfdir)
|
|
||||||
return sysconfdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func LOCALSTATEDIR() string {
|
|
||||||
wwlog.Debug("LOCALSTATEDIR = '%s'", localstatedir)
|
|
||||||
return localstatedir
|
|
||||||
}
|
|
||||||
|
|
||||||
func SRVDIR() string {
|
|
||||||
wwlog.Debug("SRVDIR = '%s'", srvdir)
|
|
||||||
return srvdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func TFTPDIR() string {
|
|
||||||
wwlog.Debug("TFTPDIR = '%s'", tftpdir)
|
|
||||||
return tftpdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func FIREWALLDDIR() string {
|
|
||||||
wwlog.Debug("FIREWALLDDIR = '%s'", firewallddir)
|
|
||||||
return firewallddir
|
|
||||||
}
|
|
||||||
|
|
||||||
func SYSTEMDDIR() string {
|
|
||||||
wwlog.Debug("SYSTEMDDIR = '%s'", systemddir)
|
|
||||||
return systemddir
|
|
||||||
}
|
|
||||||
|
|
||||||
func WWOVERLAYDIR() string {
|
|
||||||
wwlog.Debug("WWOVERLAYDIR = '%s'", wwoverlaydir)
|
|
||||||
return wwoverlaydir
|
|
||||||
}
|
|
||||||
|
|
||||||
func WWCHROOTDIR() string {
|
|
||||||
wwlog.Debug("WWCHROOTDIR = '%s'", wwchrootdir)
|
|
||||||
return wwchrootdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func WWPROVISIONDIR() string {
|
|
||||||
wwlog.Debug("WWPROVISIONDIR = '%s'", wwprovisiondir)
|
|
||||||
return wwprovisiondir
|
|
||||||
}
|
|
||||||
|
|
||||||
func VERSION() string {
|
|
||||||
wwlog.Debug("VERSION = '%s'", version)
|
|
||||||
return version
|
|
||||||
}
|
|
||||||
|
|
||||||
func RELEASE() string {
|
|
||||||
wwlog.Debug("RELEASE = '%s'", release)
|
|
||||||
return release
|
|
||||||
}
|
|
||||||
|
|
||||||
func WWCLIENTDIR() string {
|
|
||||||
wwlog.Debug("WWCLIENTDIR = '%s'", wwclientdir)
|
|
||||||
return wwclientdir
|
|
||||||
}
|
|
||||||
|
|
||||||
func TMPDIR() string {
|
|
||||||
wwlog.Debug("TMPDIR = '%s'", tmpdir)
|
|
||||||
return tmpdir
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package buildconfig
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
bindir = "@BINDIR@"
|
|
||||||
sysconfdir = "@SYSCONFDIR@"
|
|
||||||
datadir = "@DATADIR@"
|
|
||||||
localstatedir = "@LOCALSTATEDIR@"
|
|
||||||
srvdir = "@SRVDIR@"
|
|
||||||
tftpdir = "@TFTPDIR@"
|
|
||||||
firewallddir = "@FIREWALLDDIR@"
|
|
||||||
systemddir = "@SYSTEMDDIR@"
|
|
||||||
wwoverlaydir = "@WWOVERLAYDIR@"
|
|
||||||
wwchrootdir = "@WWCHROOTDIR@"
|
|
||||||
wwprovisiondir = "@WWPROVISIONDIR@"
|
|
||||||
version = "@VERSION@"
|
|
||||||
release = "@RELEASE@"
|
|
||||||
wwclientdir = "@WWCLIENTDIR@"
|
|
||||||
tmpdir = "@TMPDIR@"
|
|
||||||
}
|
|
||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||||
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
@@ -14,10 +14,10 @@ import (
|
|||||||
func SSH() error {
|
func SSH() error {
|
||||||
if os.Getuid() == 0 {
|
if os.Getuid() == 0 {
|
||||||
fmt.Printf("Updating system keys\n")
|
fmt.Printf("Updating system keys\n")
|
||||||
|
conf := warewulfconf.New()
|
||||||
|
wwkeydir := path.Join(conf.SYSCONFDIR(), "warewulf/keys") + "/"
|
||||||
|
|
||||||
wwkeydir := path.Join(buildconfig.SYSCONFDIR(), "warewulf/keys") + "/"
|
err := os.MkdirAll(path.Join(conf.SYSCONFDIR(), "warewulf/keys"), 0755)
|
||||||
|
|
||||||
err := os.MkdirAll(path.Join(buildconfig.SYSCONFDIR(), "warewulf/keys"), 0755)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Error("Could not create base directory: %s", err)
|
wwlog.Error("Could not create base directory: %s", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -5,15 +5,14 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TFTP() error {
|
func TFTP() error {
|
||||||
var tftpdir string = path.Join(buildconfig.TFTPDIR(), "warewulf")
|
|
||||||
controller := warewulfconf.New()
|
controller := warewulfconf.New()
|
||||||
|
var tftpdir string = path.Join(controller.TFTPDIR(), "warewulf")
|
||||||
|
|
||||||
err := os.MkdirAll(tftpdir, 0755)
|
err := os.MkdirAll(tftpdir, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -28,7 +27,7 @@ func TFTP() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
copyCheck[f] = true
|
copyCheck[f] = true
|
||||||
err = util.SafeCopyFile(path.Join(buildconfig.DATADIR(), f), path.Join(tftpdir, f))
|
err = util.SafeCopyFile(path.Join(controller.DATADIR(), f), path.Join(tftpdir, f))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Warn("ipxe binary could not be copied, booting may not work: %s", err)
|
wwlog.Warn("ipxe binary could not be copied, booting may not work: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ package container
|
|||||||
import (
|
import (
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SourceParentDir() string {
|
func SourceParentDir() string {
|
||||||
return buildconfig.WWCHROOTDIR()
|
conf := warewulfconf.New()
|
||||||
|
return conf.WWCHROOTDIR()
|
||||||
}
|
}
|
||||||
|
|
||||||
func SourceDir(name string) string {
|
func SourceDir(name string) string {
|
||||||
@@ -19,7 +20,8 @@ func RootFsDir(name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ImageParentDir() string {
|
func ImageParentDir() string {
|
||||||
return path.Join(buildconfig.WWPROVISIONDIR(), "container/")
|
conf := warewulfconf.New()
|
||||||
|
return path.Join(conf.WWPROVISIONDIR(), "container/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImageFile(name string) string {
|
func ImageFile(name string) string {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||||
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,7 +28,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func KernelImageTopDir() string {
|
func KernelImageTopDir() string {
|
||||||
return path.Join(buildconfig.WWPROVISIONDIR(), "kernel")
|
conf := warewulfconf.New()
|
||||||
|
return path.Join(conf.WWPROVISIONDIR(), "kernel")
|
||||||
}
|
}
|
||||||
|
|
||||||
func KernelImage(kernelName string) string {
|
func KernelImage(kernelName string) string {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
@@ -37,11 +37,12 @@ defaultnode:
|
|||||||
netmask: 255.255.255.0`
|
netmask: 255.255.255.0`
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
conf := warewulfconf.New()
|
||||||
if ConfigFile == "" {
|
if ConfigFile == "" {
|
||||||
ConfigFile = path.Join(buildconfig.SYSCONFDIR(), "warewulf/nodes.conf")
|
ConfigFile = path.Join(conf.SYSCONFDIR(), "warewulf/nodes.conf")
|
||||||
}
|
}
|
||||||
if DefaultConfig == "" {
|
if DefaultConfig == "" {
|
||||||
DefaultConfig = path.Join(buildconfig.SYSCONFDIR(), "warewulf/defaults.conf")
|
DefaultConfig = path.Join(conf.SYSCONFDIR(), "warewulf/defaults.conf")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func OverlaySourceTopDir() string {
|
func OverlaySourceTopDir() string {
|
||||||
return buildconfig.WWOVERLAYDIR()
|
conf := warewulfconf.New()
|
||||||
|
return conf.WWOVERLAYDIR()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -30,5 +31,6 @@ func OverlaySourceDir(overlayName string) string {
|
|||||||
Returns the overlay name of the image for a given node
|
Returns the overlay name of the image for a given node
|
||||||
*/
|
*/
|
||||||
func OverlayImage(nodeName string, overlayName []string) string {
|
func OverlayImage(nodeName string, overlayName []string) string {
|
||||||
return path.Join(buildconfig.WWPROVISIONDIR(), "overlays/", nodeName, strings.Join(overlayName, "-")+".img")
|
conf := warewulfconf.New()
|
||||||
|
return path.Join(conf.WWPROVISIONDIR(), "overlays/", nodeName, strings.Join(overlayName, "-")+".img")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||||
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,8 +18,9 @@ the path is relative to SYSCONFDIR.
|
|||||||
Templates in the file are no evaluated.
|
Templates in the file are no evaluated.
|
||||||
*/
|
*/
|
||||||
func templateFileInclude(inc string) string {
|
func templateFileInclude(inc string) string {
|
||||||
|
conf := warewulfconf.New()
|
||||||
if !strings.HasPrefix(inc, "/") {
|
if !strings.HasPrefix(inc, "/") {
|
||||||
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
|
inc = path.Join(conf.SYSCONFDIR(), "warewulf", inc)
|
||||||
}
|
}
|
||||||
wwlog.Debug("Including file into template: %s", inc)
|
wwlog.Debug("Including file into template: %s", inc)
|
||||||
content, err := os.ReadFile(inc)
|
content, err := os.ReadFile(inc)
|
||||||
@@ -35,8 +36,9 @@ is the file to read, the second the abort string
|
|||||||
Templates in the file are no evaluated.
|
Templates in the file are no evaluated.
|
||||||
*/
|
*/
|
||||||
func templateFileBlock(inc string, abortStr string) (string, error) {
|
func templateFileBlock(inc string, abortStr string) (string, error) {
|
||||||
|
conf := warewulfconf.New()
|
||||||
if !strings.HasPrefix(inc, "/") {
|
if !strings.HasPrefix(inc, "/") {
|
||||||
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
|
inc = path.Join(conf.SYSCONFDIR(), "warewulf", inc)
|
||||||
}
|
}
|
||||||
wwlog.Debug("Including file block into template: %s", inc)
|
wwlog.Debug("Including file block into template: %s", inc)
|
||||||
readFile, err := os.Open(inc)
|
readFile, err := os.Open(inc)
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1"
|
"github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return the version of wwctl
|
Return the version of wwctl
|
||||||
*/
|
*/
|
||||||
func GetVersion() string {
|
func GetVersion() string {
|
||||||
return fmt.Sprintf("%s-%s", buildconfig.VERSION(), buildconfig.RELEASE())
|
conf := warewulfconf.New()
|
||||||
|
return fmt.Sprintf("%s-%s", conf.VERSION(), conf.RELEASE())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
18
internal/pkg/warewulfconf/buildconfig.go.in
Normal file
18
internal/pkg/warewulfconf/buildconfig.go.in
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package warewulfconf
|
||||||
|
|
||||||
|
type BuildConfig struct {
|
||||||
|
bindir string `default:"@BINDIR@"`
|
||||||
|
sysconfdir string `default:"@SYSCONFDIR@"`
|
||||||
|
datadir string `default:"@DATADIR@"`
|
||||||
|
localstatedir string `default:"@LOCALSTATEDIR@"`
|
||||||
|
srvdir string `default:"@SRVDIR@"`
|
||||||
|
tftpdir string `default:"@TFTPDIR@"`
|
||||||
|
firewallddir string `default:"@FIREWALLDDIR@"`
|
||||||
|
systemddir string `default:"@SYSTEMDDIR@"`
|
||||||
|
wwoverlaydir string `default:"@WWOVERLAYDIR@"`
|
||||||
|
wwchrootdir string `default:"@WWCHROOTDIR@"`
|
||||||
|
wwprovisiondir string `default:"@WWPROVISIONDIR@"`
|
||||||
|
version string `default:"@VERSION@"`
|
||||||
|
release string `default:"@RELEASE@"`
|
||||||
|
wwclientdir string `default:"@WWCLIENTDIR@"`
|
||||||
|
}
|
||||||
@@ -5,11 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
|
|
||||||
"github.com/brotherpowers/ipsubnet"
|
"github.com/brotherpowers/ipsubnet"
|
||||||
"github.com/creasty/defaults"
|
"github.com/creasty/defaults"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
@@ -18,18 +16,6 @@ var cachedConf ControllerConf
|
|||||||
|
|
||||||
var ConfigFile string
|
var ConfigFile string
|
||||||
|
|
||||||
/*
|
|
||||||
Get the configFile location from the os.ev if set
|
|
||||||
*/
|
|
||||||
func init() {
|
|
||||||
if ConfigFile == "" {
|
|
||||||
ConfigFile = os.Getenv("WARWULFCONF")
|
|
||||||
}
|
|
||||||
if ConfigFile == "" {
|
|
||||||
ConfigFile = path.Join(buildconfig.SYSCONFDIR(), "warewulf/warewulf.conf")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates a new empty ControllerConf object, returns a cached
|
Creates a new empty ControllerConf object, returns a cached
|
||||||
one if called in a nother context.
|
one if called in a nother context.
|
||||||
@@ -42,10 +28,9 @@ func New() (ret ControllerConf) {
|
|||||||
ret.Dhcp = new(DhcpConf)
|
ret.Dhcp = new(DhcpConf)
|
||||||
ret.Tftp = new(TftpConf)
|
ret.Tftp = new(TftpConf)
|
||||||
ret.Nfs = new(NfsConf)
|
ret.Nfs = new(NfsConf)
|
||||||
err := defaults.Set(&ret)
|
ret.Paths = new(BuildConfig)
|
||||||
if err != nil {
|
_ = defaults.Set(&ret)
|
||||||
ret.setDynamicDefaults()
|
ret.setDynamicDefaults()
|
||||||
}
|
|
||||||
|
|
||||||
cachedConf = ret
|
cachedConf = ret
|
||||||
cachedConf.current = true
|
cachedConf.current = true
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type ControllerConf struct {
|
|||||||
Tftp *TftpConf `yaml:"tftp"`
|
Tftp *TftpConf `yaml:"tftp"`
|
||||||
Nfs *NfsConf `yaml:"nfs"`
|
Nfs *NfsConf `yaml:"nfs"`
|
||||||
MountsContainer []*MountEntry `yaml:"container mounts" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"`
|
MountsContainer []*MountEntry `yaml:"container mounts" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"`
|
||||||
|
Paths *BuildConfig `yaml:"mypaths"`
|
||||||
current bool
|
current bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
73
internal/pkg/warewulfconf/getter.go
Normal file
73
internal/pkg/warewulfconf/getter.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package warewulfconf
|
||||||
|
|
||||||
|
import "github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
|
|
||||||
|
func (conf *ControllerConf) BINDIR() string {
|
||||||
|
wwlog.Debug("BINDIR = '%s'", conf.Paths.bindir)
|
||||||
|
return conf.Paths.bindir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) DATADIR() string {
|
||||||
|
wwlog.Debug("DATADIR = '%s'", conf.Paths.datadir)
|
||||||
|
return conf.Paths.datadir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) SYSCONFDIR() string {
|
||||||
|
wwlog.Debug("SYSCONFDIR = '%s'", conf.Paths.sysconfdir)
|
||||||
|
return conf.Paths.sysconfdir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) LOCALSTATEDIR() string {
|
||||||
|
wwlog.Debug("LOCALSTATEDIR = '%s'", conf.Paths.localstatedir)
|
||||||
|
return conf.Paths.localstatedir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) SRVDIR() string {
|
||||||
|
wwlog.Debug("SRVDIR = '%s'", conf.Paths.srvdir)
|
||||||
|
return conf.Paths.srvdir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) TFTPDIR() string {
|
||||||
|
wwlog.Debug("TFTPDIR = '%s'", conf.Paths.tftpdir)
|
||||||
|
return conf.Paths.tftpdir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) FIREWALLDDIR() string {
|
||||||
|
wwlog.Debug("FIREWALLDDIR = '%s'", conf.Paths.firewallddir)
|
||||||
|
return conf.Paths.firewallddir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) SYSTEMDDIR() string {
|
||||||
|
wwlog.Debug("SYSTEMDDIR = '%s'", conf.Paths.systemddir)
|
||||||
|
return conf.Paths.systemddir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) WWOVERLAYDIR() string {
|
||||||
|
wwlog.Debug("WWOVERLAYDIR = '%s'", conf.Paths.wwoverlaydir)
|
||||||
|
return conf.Paths.wwoverlaydir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) WWCHROOTDIR() string {
|
||||||
|
wwlog.Debug("WWCHROOTDIR = '%s'", conf.Paths.wwchrootdir)
|
||||||
|
return conf.Paths.wwchrootdir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) WWPROVISIONDIR() string {
|
||||||
|
wwlog.Debug("WWPROVISIONDIR = '%s'", conf.Paths.wwprovisiondir)
|
||||||
|
return conf.Paths.wwprovisiondir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) VERSION() string {
|
||||||
|
wwlog.Debug("VERSION = '%s'", conf.Paths.version)
|
||||||
|
return conf.Paths.version
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) RELEASE() string {
|
||||||
|
wwlog.Debug("RELEASE = '%s'", conf.Paths.release)
|
||||||
|
return conf.Paths.release
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conf *ControllerConf) WWCLIENTDIR() string {
|
||||||
|
wwlog.Debug("WWCLIENTDIR = '%s'", conf.Paths.wwclientdir)
|
||||||
|
return conf.Paths.wwclientdir
|
||||||
|
}
|
||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||||
@@ -80,13 +79,13 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
|
|||||||
if !node.Id.Defined() {
|
if !node.Id.Defined() {
|
||||||
wwlog.Error("%s (unknown/unconfigured node)", rinfo.hwaddr)
|
wwlog.Error("%s (unknown/unconfigured node)", rinfo.hwaddr)
|
||||||
if rinfo.stage == "ipxe" {
|
if rinfo.stage == "ipxe" {
|
||||||
stage_file = path.Join(buildconfig.SYSCONFDIR(), "/warewulf/ipxe/unconfigured.ipxe")
|
stage_file = path.Join(conf.SYSCONFDIR(), "/warewulf/ipxe/unconfigured.ipxe")
|
||||||
tmpl_data = iPxeTemplate{
|
tmpl_data = iPxeTemplate{
|
||||||
Hwaddr: rinfo.hwaddr}
|
Hwaddr: rinfo.hwaddr}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if rinfo.stage == "ipxe" {
|
} else if rinfo.stage == "ipxe" {
|
||||||
stage_file = path.Join(buildconfig.SYSCONFDIR(), "warewulf/ipxe/"+node.Ipxe.Get()+".ipxe")
|
stage_file = path.Join(conf.SYSCONFDIR(), "warewulf/ipxe/"+node.Ipxe.Get()+".ipxe")
|
||||||
tmpl_data = iPxeTemplate{
|
tmpl_data = iPxeTemplate{
|
||||||
Id: node.Id.Get(),
|
Id: node.Id.Get(),
|
||||||
Cluster: node.ClusterName.Get(),
|
Cluster: node.ClusterName.Get(),
|
||||||
|
|||||||
Reference in New Issue
Block a user