Merge pull request #1037 from mslacken/ConfigClean

removed double entries from paths
This commit is contained in:
Jonathon Anderson
2024-02-16 17:49:55 -07:00
committed by GitHub
12 changed files with 51 additions and 48 deletions

View File

@@ -149,6 +149,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- move hostlist into internal alongside other warewulf code #804
- uniform shebang usage in scripts of init.d folder #821
- Check if commas are allowes in node/profile set
- Removed paths.tftpdir and paths.datadir
## [4.4.0] 2023-01-18

View File

@@ -106,7 +106,8 @@ install: build docs
install -d -m 0755 $(DESTDIR)$(SYSTEMDDIR)
install -d -m 0755 $(DESTDIR)$(IPXESOURCE)
install -d -m 0755 $(DESTDIR)$(DATADIR)/warewulf
test -f $(DESTDIR)$(WWCONFIGDIR)/warewulf.conf || install -m 0644 etc/warewulf.conf $(DESTDIR)$(WWCONFIGDIR)
# wwctl genconfig to get the compiled in paths to warewulf.conf
test -f $(DESTDIR)$(WWCONFIGDIR)/warewulf.conf || ./wwctl --warewulfconf etc/warewulf.conf genconfig warewulfconf print> $(DESTDIR)$(WWCONFIGDIR)/warewulf.conf
test -f $(DESTDIR)$(WWCONFIGDIR)/nodes.conf || install -m 0644 etc/nodes.conf $(DESTDIR)$(WWCONFIGDIR)
test -f $(DESTDIR)$(WWCONFIGDIR)/wwapic.conf || install -m 0644 etc/wwapic.conf $(DESTDIR)$(WWCONFIGDIR)
test -f $(DESTDIR)$(WWCONFIGDIR)/wwapid.conf || install -m 0644 etc/wwapid.conf $(DESTDIR)$(WWCONFIGDIR)

View File

@@ -5,17 +5,44 @@ var ConfigFile = "@SYSCONFDIR@/warewulf/warewulf.conf"
type BuildConfig struct {
Bindir string `default:"@BINDIR@"`
Sysconfdir string `default:"@SYSCONFDIR@"`
Datadir string `default:"@DATADIR@"`
Localstatedir string `default:"@LOCALSTATEDIR@"`
Ipxesource string `default:"@IPXESOURCE@"`
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@"`
version string `default:"@VERSION@"`
release string `default:"@RELEASE@"`
}
func (conf BuildConfig) Version() string {
return conf.version
}
func (conf BuildConfig) Release() string {
return conf.release
}
type TFTPConf struct {
Enabled bool `yaml:"enabled" default:"true"`
TftpRoot string `yaml:"tftproot" default:"@TFTPDIR@"`
SystemdName string `yaml:"systemd name" default:"tftp"`
IpxeBinaries map[string]string `yaml:"ipxe" default:"{\"00:09\": \"ipxe-snponly-x86_64.efi\",\"00:00\": \"undionly.kpxe\",\"00:0B\": \"arm64-efi/snponly.efi\",\"00:07\": \"ipxe-snponly-x86_64.efi\"}"`
}
// WarewulfConf adds additional Warewulf-specific configuration to
// BaseConf.
type WarewulfConf struct {
Port int `yaml:"port" default:"9983"`
Secure bool `yaml:"secure" default:"true"`
UpdateInterval int `yaml:"update interval" default:"60"`
AutobuildOverlays bool `yaml:"autobuild overlays" default:"true"`
EnableHostOverlay bool `yaml:"host overlay" default:"true"`
Syslog bool `yaml:"syslog" default:"false"`
DataStore string `yaml:"datastore" default:"@DATADIR@"`
GrubBoot bool `yaml:"grubboot" default:"false"`
}

View File

@@ -3,8 +3,8 @@ package config
// A MountEntry represents a bind mount that is applied to a container
// during exec and shell.
type MountEntry struct {
Source string `yaml:"source" default:"/etc/resolv.conf"`
Dest string `yaml:"dest,omitempty" default:"/etc/resolv.conf"`
ReadOnly bool `yaml:"readonly,omitempty" default:"false"`
Source string `yaml:"source"`
Dest string `yaml:"dest,omitempty"`
ReadOnly bool `yaml:"readonly,omitempty"`
Options string `yaml:"options,omitempty"` // ignored at the moment
}

View File

@@ -43,10 +43,9 @@ func TestDefaultRootConf(t *testing.T) {
assert.NotEmpty(t, conf.Paths.Bindir)
assert.NotEmpty(t, conf.Paths.Sysconfdir)
assert.NotEmpty(t, conf.Paths.Datadir)
assert.NotEmpty(t, conf.Warewulf.DataStore)
assert.NotEmpty(t, conf.Paths.Localstatedir)
assert.NotEmpty(t, conf.Paths.Srvdir)
assert.NotEmpty(t, conf.Paths.Tftpdir)
assert.NotEmpty(t, conf.Paths.Firewallddir)
assert.NotEmpty(t, conf.Paths.Systemddir)
assert.NotEmpty(t, conf.Paths.WWOverlaydir)

View File

@@ -1,11 +0,0 @@
package config
// TFTPConf represents that configuration for the TFTP service that
// Warewulf will configure.
type TFTPConf struct {
Enabled bool `yaml:"enabled" default:"true"`
TftpRoot string `yaml:"tftproot" default:"/var/lib/tftpboot"`
SystemdName string `yaml:"systemd name" default:"tftp"`
IpxeBinaries map[string]string `yaml:"ipxe" default:"{\"00:09\": \"ipxe-snponly-x86_64.efi\",\"00:00\": \"undionly.kpxe\",\"00:0B\": \"arm64-efi/snponly.efi\",\"00:07\": \"ipxe-snponly-x86_64.efi\"}"`
}

View File

@@ -1,14 +0,0 @@
package config
// WarewulfConf adds additional Warewulf-specific configuration to
// BaseConf.
type WarewulfConf struct {
Port int `yaml:"port" default:"9983"`
Secure bool `yaml:"secure" default:"true"`
UpdateInterval int `yaml:"update interval" default:"60"`
AutobuildOverlays bool `yaml:"autobuild overlays" default:"true"`
EnableHostOverlay bool `yaml:"host overlay" default:"true"`
Syslog bool `yaml:"syslog" default:"false"`
DataStore string `yaml:"datastore" default:"/var/lib/warewulf"`
GrubBoot bool `yaml:"grubboot" default:"false"`
}

View File

@@ -12,7 +12,7 @@ import (
func TFTP() error {
controller := warewulfconf.Get()
var tftpdir string = path.Join(controller.Paths.Tftpdir, "warewulf")
var tftpdir string = path.Join(controller.TFTP.TftpRoot, "warewulf")
err := os.MkdirAll(tftpdir, 0755)
if err != nil {

View File

@@ -49,7 +49,7 @@ func New() (NodeYaml, error) {
ConfigFile = path.Join(conf.Paths.Sysconfdir, "warewulf/nodes.conf")
}
if DefaultConfig == "" {
DefaultConfig = path.Join(conf.Paths.Datadir, "warewulf/defaults.conf")
DefaultConfig = path.Join(conf.Warewulf.DataStore, "warewulf/defaults.conf")
}
wwlog.Verbose("Opening node configuration file: %s", ConfigFile)
data, err := os.ReadFile(ConfigFile)

View File

@@ -68,10 +68,10 @@ func New(t *testing.T) (env *TestEnv) {
conf.Paths.Sysconfdir = env.GetPath(Sysconfdir)
conf.Paths.Bindir = env.GetPath(Bindir)
conf.Paths.Datadir = env.GetPath(Datadir)
conf.Warewulf.DataStore = env.GetPath(Datadir)
conf.Paths.Localstatedir = env.GetPath(Localstatedir)
conf.Paths.Srvdir = env.GetPath(Srvdir)
conf.Paths.Tftpdir = env.GetPath(Tftpdir)
conf.TFTP.TftpRoot = env.GetPath(Tftpdir)
conf.Paths.Firewallddir = env.GetPath(Firewallddir)
conf.Paths.Systemddir = env.GetPath(Systemddir)
conf.Paths.WWOverlaydir = env.GetPath(WWOverlaydir)
@@ -82,10 +82,10 @@ func New(t *testing.T) (env *TestEnv) {
for _, confPath := range []string{
conf.Paths.Sysconfdir,
conf.Paths.Bindir,
conf.Paths.Datadir,
conf.Warewulf.DataStore,
conf.Paths.Localstatedir,
conf.Paths.Srvdir,
conf.Paths.Tftpdir,
conf.TFTP.TftpRoot,
conf.Paths.Firewallddir,
conf.Paths.Systemddir,
conf.Paths.WWOverlaydir,

View File

@@ -12,7 +12,7 @@ Return the version of wwctl
*/
func GetVersion() string {
conf := warewulfconf.Get()
return fmt.Sprintf("%s-%s", conf.Paths.Version, conf.Paths.Release)
return fmt.Sprintf("%s-%s", conf.Paths.Version(), conf.Paths.Release())
}
/*

View File

@@ -24,22 +24,22 @@ func CopyShimGrub() (err error) {
if shimPath == "" {
return fmt.Errorf("no shim found on the host os")
}
err = util.CopyFile(shimPath, path.Join(conf.Paths.Tftpdir, "warewulf", "shim.efi"))
err = util.CopyFile(shimPath, path.Join(conf.TFTP.TftpRoot, "warewulf", "shim.efi"))
if err != nil {
return err
}
_ = os.Chmod(path.Join(conf.Paths.Tftpdir, "warewulf", "shim.efi"), 0o755)
_ = os.Chmod(path.Join(conf.TFTP.TftpRoot, "warewulf", "shim.efi"), 0o755)
grubPath := container.GrubFind("")
if grubPath == "" {
return fmt.Errorf("no grub found on host os")
}
err = util.CopyFile(grubPath, path.Join(conf.Paths.Tftpdir, "warewulf", "grub.efi"))
err = util.CopyFile(grubPath, path.Join(conf.TFTP.TftpRoot, "warewulf", "grub.efi"))
if err != nil {
return err
}
_ = os.Chmod(path.Join(conf.Paths.Tftpdir, "warewulf", "grub.efi"), 0o755)
err = util.CopyFile(grubPath, path.Join(conf.Paths.Tftpdir, "warewulf", "grubx64.efi"))
_ = os.Chmod(path.Join(conf.Paths.Tftpdir, "warewulf", "grubx64.efi"), 0o755)
_ = os.Chmod(path.Join(conf.TFTP.TftpRoot, "warewulf", "grub.efi"), 0o755)
err = util.CopyFile(grubPath, path.Join(conf.TFTP.TftpRoot, "warewulf", "grubx64.efi"))
_ = os.Chmod(path.Join(conf.TFTP.TftpRoot, "warewulf", "grubx64.efi"), 0o755)
return
}