Convert config to *bool
Supports leaving booleans unspecified in YAML. Boolean methods allow the templates to continue using previous names for boolean values. Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -102,7 +102,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
if conf.WWClient != nil && conf.WWClient.Port > 0 {
|
||||
localTCPAddr.Port = int(conf.WWClient.Port)
|
||||
wwlog.Info("Running from configured port %d", conf.WWClient.Port)
|
||||
} else if conf.Warewulf.Secure {
|
||||
} else if conf.Warewulf.Secure() {
|
||||
// Setup local port to something privileged (<1024)
|
||||
localTCPAddr.Port = 987
|
||||
wwlog.Info("Running from trusted port")
|
||||
|
||||
@@ -134,14 +134,14 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
}
|
||||
|
||||
for _, mntPnt := range mountPts {
|
||||
if mntPnt.Copy {
|
||||
if mntPnt.Copy() {
|
||||
continue
|
||||
}
|
||||
wwlog.Debug("bind mounting: %s -> %s", mntPnt.Source, path.Join(containerPath, mntPnt.Dest))
|
||||
err = syscall.Mount(mntPnt.Source, path.Join(containerPath, mntPnt.Dest), "", syscall.MS_BIND, "")
|
||||
if err != nil {
|
||||
wwlog.Warn("Couldn't mount %s to %s: %s", mntPnt.Source, mntPnt.Dest, err)
|
||||
} else if mntPnt.ReadOnly {
|
||||
} else if mntPnt.ReadOnly() {
|
||||
err = syscall.Mount(mntPnt.Source, path.Join(containerPath, mntPnt.Dest), "", syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_BIND, "")
|
||||
if err != nil {
|
||||
wwlog.Warn("failed to following mount readonly: %s", mntPnt.Source)
|
||||
@@ -191,7 +191,7 @@ the invalid mount points. Directories always have '/' as suffix
|
||||
func checkMountPoints(containerName string, binds []*warewulfconf.MountEntry) (overlayObjects []string) {
|
||||
overlayObjects = []string{}
|
||||
for _, b := range binds {
|
||||
if b.Copy {
|
||||
if b.Copy() {
|
||||
continue
|
||||
}
|
||||
_, err := os.Stat(b.Source)
|
||||
|
||||
@@ -229,7 +229,7 @@ Check the objects we want to copy in, instead of mounting
|
||||
*/
|
||||
func getCopyFiles(binds []*warewulfconf.MountEntry) (copyObjects []*copyFile) {
|
||||
for _, bind := range binds {
|
||||
if bind.Copy {
|
||||
if bind.Copy() {
|
||||
copyObjects = append(copyObjects, ©File{
|
||||
fileName: bind.Dest,
|
||||
src: bind.Source,
|
||||
|
||||
@@ -71,7 +71,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
}
|
||||
|
||||
if BuildHost && controller.Warewulf.EnableHostOverlay {
|
||||
if BuildHost && controller.Warewulf.EnableHostOverlay() {
|
||||
err := overlay.BuildHostOverlay()
|
||||
if err != nil {
|
||||
return fmt.Errorf("host overlay could not be built: %s", err)
|
||||
|
||||
@@ -2,6 +2,8 @@ package config
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
)
|
||||
|
||||
var ConfigFile = "@SYSCONFDIR@/warewulf/warewulf.conf"
|
||||
@@ -25,24 +27,48 @@ const Version = "@VERSION@"
|
||||
const Release = "@RELEASE@"
|
||||
|
||||
type TFTPConf struct {
|
||||
Enabled bool `yaml:"enabled" default:"true"`
|
||||
EnabledP *bool `yaml:"enabled" default:"true"`
|
||||
TftpRoot string `yaml:"tftproot,omitempty" default:"@TFTPDIR@"`
|
||||
SystemdName string `yaml:"systemd name,omitempty" default:"tftp"`
|
||||
|
||||
IpxeBinaries map[string]string `yaml:"ipxe,omitempty" 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\"}"`
|
||||
}
|
||||
|
||||
func (this TFTPConf) Enabled() bool {
|
||||
return util.BoolP(this.EnabledP)
|
||||
}
|
||||
|
||||
// WarewulfConf adds additional Warewulf-specific configuration to
|
||||
// BaseConf.
|
||||
type WarewulfConf struct {
|
||||
Port int `yaml:"port,omitempty" default:"9873"`
|
||||
Secure bool `yaml:"secure" default:"true"`
|
||||
UpdateInterval int `yaml:"update interval,omitempty" default:"60"`
|
||||
AutobuildOverlays bool `yaml:"autobuild overlays,omitempty" default:"true"`
|
||||
EnableHostOverlay bool `yaml:"host overlay" default:"true"`
|
||||
Syslog bool `yaml:"syslog,omitempty" default:"false"`
|
||||
DataStore string `yaml:"datastore,omitempty" default:"@DATADIR@"`
|
||||
GrubBoot bool `yaml:"grubboot,omitempty" default:"false"`
|
||||
Port int `yaml:"port,omitempty" default:"9873"`
|
||||
SecureP *bool `yaml:"secure,omitempty" default:"true"`
|
||||
UpdateInterval int `yaml:"update interval,omitempty" default:"60"`
|
||||
AutobuildOverlaysP *bool `yaml:"autobuild overlays,omitempty" default:"true"`
|
||||
EnableHostOverlayP *bool `yaml:"host overlay,omitempty" default:"true"`
|
||||
SyslogP *bool `yaml:"syslog,omitempty" default:"false"`
|
||||
DataStore string `yaml:"datastore,omitempty" default:"@DATADIR@"`
|
||||
GrubBootP *bool `yaml:"grubboot,omitempty" default:"false"`
|
||||
}
|
||||
|
||||
func (this WarewulfConf) Secure() bool {
|
||||
return util.BoolP(this.SecureP)
|
||||
}
|
||||
|
||||
func (this WarewulfConf) AutobuildOverlays() bool {
|
||||
return util.BoolP(this.AutobuildOverlaysP)
|
||||
}
|
||||
|
||||
func (this WarewulfConf) EnableHostOverlay() bool {
|
||||
return util.BoolP(this.EnableHostOverlayP)
|
||||
}
|
||||
|
||||
func (this WarewulfConf) Syslog() bool {
|
||||
return util.BoolP(this.SyslogP)
|
||||
}
|
||||
|
||||
func (this WarewulfConf) GrubBoot() bool {
|
||||
return util.BoolP(this.GrubBootP)
|
||||
}
|
||||
|
||||
func (paths BuildConfig) OciBlobCachedir() string {
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
)
|
||||
|
||||
// DHCPConf represents the configuration for the DHCP service that
|
||||
// Warewulf will configure.
|
||||
type DHCPConf struct {
|
||||
Enabled bool `yaml:"enabled" default:"true"`
|
||||
EnabledP *bool `yaml:"enabled,omitempty" default:"true"`
|
||||
Template string `yaml:"template,omitempty" default:"default"`
|
||||
RangeStart string `yaml:"range start,omitempty"`
|
||||
RangeEnd string `yaml:"range end,omitempty"`
|
||||
SystemdName string `yaml:"systemd name,omitempty" default:"dhcpd"`
|
||||
}
|
||||
|
||||
func (this DHCPConf) Enabled() bool {
|
||||
return util.BoolP(this.EnabledP)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
)
|
||||
|
||||
// A MountEntry represents a bind mount that is applied to a container
|
||||
// during exec and shell.
|
||||
type MountEntry struct {
|
||||
Source string `yaml:"source"`
|
||||
Dest string `yaml:"dest,omitempty"`
|
||||
ReadOnly bool `yaml:"readonly,omitempty"`
|
||||
Options string `yaml:"options,omitempty"` // ignored at the moment
|
||||
Copy bool `yaml:"copy,omitempty"` // temporarily copy the file into the container
|
||||
Source string `yaml:"source"`
|
||||
Dest string `yaml:"dest,omitempty"`
|
||||
ReadOnlyP *bool `yaml:"readonly,omitempty"`
|
||||
Options string `yaml:"options,omitempty"` // ignored at the moment
|
||||
CopyP *bool `yaml:"copy,omitempty"` // temporarily copy the file into the container
|
||||
}
|
||||
|
||||
func (this MountEntry) ReadOnly() bool {
|
||||
return util.BoolP(this.ReadOnlyP)
|
||||
}
|
||||
|
||||
func (this MountEntry) Copy() bool {
|
||||
return util.BoolP(this.CopyP)
|
||||
}
|
||||
|
||||
@@ -2,23 +2,33 @@ package config
|
||||
|
||||
import (
|
||||
"github.com/creasty/defaults"
|
||||
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
)
|
||||
|
||||
// NFSConf represents the NFS configuration that will be used by
|
||||
// Warewulf to generate exports on the server and mounts on compute
|
||||
// nodes.
|
||||
type NFSConf struct {
|
||||
Enabled bool `yaml:"enabled" default:"true"`
|
||||
EnabledP *bool `yaml:"enabled,omitempty" default:"true"`
|
||||
ExportsExtended []*NFSExportConf `yaml:"export paths,omitempty" default:"[]"`
|
||||
SystemdName string `yaml:"systemd name,omitempty" default:"nfsd"`
|
||||
}
|
||||
|
||||
func (this NFSConf) Enabled() bool {
|
||||
return util.BoolP(this.EnabledP)
|
||||
}
|
||||
|
||||
// An NFSExportConf reprents a single NFS export / mount.
|
||||
type NFSExportConf struct {
|
||||
Path string `yaml:"path" default:"/dev/null"`
|
||||
ExportOptions string `yaml:"export options,omitempty" default:"rw,sync,no_subtree_check"`
|
||||
MountOptions string `yaml:"mount options,omitempty" default:"defaults"`
|
||||
Mount bool `yaml:"mount" default:"true"`
|
||||
MountP *bool `yaml:"mount,omitempty" default:"true"`
|
||||
}
|
||||
|
||||
func (this NFSExportConf) Mount() bool {
|
||||
return util.BoolP(this.MountP)
|
||||
}
|
||||
|
||||
// Implements the Unmarshal interface for NFSConf to set default
|
||||
|
||||
@@ -114,7 +114,6 @@ func (conf *WarewulfYaml) Parse(data []byte) error {
|
||||
conf.Netmask = fmt.Sprintf("%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3])
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -11,19 +11,19 @@ func TestDefaultWarewulfYaml(t *testing.T) {
|
||||
conf := New()
|
||||
|
||||
assert.Equal(t, 9873, conf.Warewulf.Port)
|
||||
assert.True(t, conf.Warewulf.Secure)
|
||||
assert.True(t, conf.Warewulf.Secure())
|
||||
assert.Equal(t, 60, conf.Warewulf.UpdateInterval)
|
||||
assert.True(t, conf.Warewulf.AutobuildOverlays)
|
||||
assert.True(t, conf.Warewulf.EnableHostOverlay)
|
||||
assert.False(t, conf.Warewulf.Syslog)
|
||||
assert.True(t, conf.Warewulf.AutobuildOverlays())
|
||||
assert.True(t, conf.Warewulf.EnableHostOverlay())
|
||||
assert.False(t, conf.Warewulf.Syslog())
|
||||
|
||||
assert.True(t, conf.DHCP.Enabled)
|
||||
assert.True(t, conf.DHCP.Enabled())
|
||||
assert.Equal(t, "default", conf.DHCP.Template)
|
||||
assert.Empty(t, conf.DHCP.RangeStart)
|
||||
assert.Empty(t, conf.DHCP.RangeEnd)
|
||||
assert.Equal(t, "dhcpd", conf.DHCP.SystemdName)
|
||||
|
||||
assert.True(t, conf.TFTP.Enabled)
|
||||
assert.True(t, conf.TFTP.Enabled())
|
||||
assert.NotEmpty(t, conf.TFTP.TftpRoot)
|
||||
assert.Equal(t, "tftp", conf.TFTP.SystemdName)
|
||||
assert.NotEmpty(t, conf.TFTP.IpxeBinaries["00:00"])
|
||||
@@ -31,13 +31,13 @@ func TestDefaultWarewulfYaml(t *testing.T) {
|
||||
assert.NotEmpty(t, conf.TFTP.IpxeBinaries["00:09"])
|
||||
assert.NotEmpty(t, conf.TFTP.IpxeBinaries["00:0B"])
|
||||
|
||||
assert.True(t, conf.NFS.Enabled)
|
||||
assert.True(t, conf.NFS.Enabled())
|
||||
assert.Empty(t, conf.NFS.ExportsExtended)
|
||||
assert.Equal(t, "nfsd", conf.NFS.SystemdName)
|
||||
|
||||
assert.Equal(t, "/etc/resolv.conf", conf.MountsContainer[0].Source)
|
||||
assert.Equal(t, "/etc/resolv.conf", conf.MountsContainer[0].Dest)
|
||||
assert.False(t, conf.MountsContainer[0].ReadOnly)
|
||||
assert.False(t, conf.MountsContainer[0].ReadOnly())
|
||||
assert.Empty(t, conf.MountsContainer[0].Options)
|
||||
|
||||
assert.NotEmpty(t, conf.Paths.Bindir)
|
||||
@@ -121,34 +121,34 @@ container mounts:
|
||||
assert.Equal(t, "192.168.200.0", conf.Network)
|
||||
|
||||
assert.Equal(t, 9873, conf.Warewulf.Port)
|
||||
assert.False(t, conf.Warewulf.Secure)
|
||||
assert.False(t, conf.Warewulf.Secure())
|
||||
assert.Equal(t, 60, conf.Warewulf.UpdateInterval)
|
||||
assert.True(t, conf.Warewulf.AutobuildOverlays)
|
||||
assert.True(t, conf.Warewulf.EnableHostOverlay)
|
||||
assert.False(t, conf.Warewulf.Syslog)
|
||||
assert.True(t, conf.Warewulf.AutobuildOverlays())
|
||||
assert.True(t, conf.Warewulf.EnableHostOverlay())
|
||||
assert.False(t, conf.Warewulf.Syslog())
|
||||
|
||||
assert.True(t, conf.DHCP.Enabled)
|
||||
assert.True(t, conf.DHCP.Enabled())
|
||||
assert.Equal(t, "192.168.200.50", conf.DHCP.RangeStart)
|
||||
assert.Equal(t, "192.168.200.99", conf.DHCP.RangeEnd)
|
||||
assert.Equal(t, "dhcpd", conf.DHCP.SystemdName)
|
||||
|
||||
assert.True(t, conf.TFTP.Enabled)
|
||||
assert.True(t, conf.TFTP.Enabled())
|
||||
assert.Equal(t, "tftp", conf.TFTP.SystemdName)
|
||||
|
||||
assert.True(t, conf.NFS.Enabled)
|
||||
assert.True(t, conf.NFS.Enabled())
|
||||
assert.Equal(t, "/home", conf.NFS.ExportsExtended[0].Path)
|
||||
assert.Equal(t, "rw,sync", conf.NFS.ExportsExtended[0].ExportOptions)
|
||||
assert.Equal(t, "defaults", conf.NFS.ExportsExtended[0].MountOptions)
|
||||
assert.True(t, conf.NFS.ExportsExtended[0].Mount)
|
||||
assert.True(t, conf.NFS.ExportsExtended[0].Mount())
|
||||
assert.Equal(t, "/opt", conf.NFS.ExportsExtended[1].Path)
|
||||
assert.Equal(t, "ro,sync,no_root_squash", conf.NFS.ExportsExtended[1].ExportOptions)
|
||||
assert.Equal(t, "defaults", conf.NFS.ExportsExtended[1].MountOptions)
|
||||
assert.False(t, conf.NFS.ExportsExtended[1].Mount)
|
||||
assert.False(t, conf.NFS.ExportsExtended[1].Mount())
|
||||
assert.Equal(t, "nfs-server", conf.NFS.SystemdName)
|
||||
|
||||
assert.Equal(t, "/etc/resolv.conf", conf.MountsContainer[0].Source)
|
||||
assert.Equal(t, "/etc/resolv.conf", conf.MountsContainer[0].Dest)
|
||||
assert.True(t, conf.MountsContainer[0].ReadOnly)
|
||||
assert.True(t, conf.MountsContainer[0].ReadOnly())
|
||||
}
|
||||
|
||||
func TestCache(t *testing.T) {
|
||||
|
||||
@@ -17,7 +17,7 @@ func DHCP() (err error) {
|
||||
|
||||
controller := warewulfconf.Get()
|
||||
|
||||
if !controller.DHCP.Enabled {
|
||||
if !controller.DHCP.Enabled() {
|
||||
wwlog.Warn("This system is not configured as a Warewulf DHCP controller")
|
||||
return
|
||||
}
|
||||
@@ -29,7 +29,7 @@ func DHCP() (err error) {
|
||||
if controller.DHCP.RangeEnd == "" {
|
||||
return fmt.Errorf("configuration is not defined: `dhcpd range end`")
|
||||
}
|
||||
if controller.Warewulf.EnableHostOverlay {
|
||||
if controller.Warewulf.EnableHostOverlay() {
|
||||
err = overlay.BuildHostOverlay()
|
||||
if err != nil {
|
||||
wwlog.Warn("host overlay could not be built: %s", err)
|
||||
|
||||
@@ -17,8 +17,8 @@ func NFS() error {
|
||||
|
||||
controller := warewulfconf.Get()
|
||||
|
||||
if controller.NFS.Enabled {
|
||||
if controller.Warewulf.EnableHostOverlay {
|
||||
if controller.NFS.Enabled() {
|
||||
if controller.Warewulf.EnableHostOverlay() {
|
||||
err := overlay.BuildHostOverlay()
|
||||
if err != nil {
|
||||
wwlog.Warn("host overlay could not be built: %s", err)
|
||||
|
||||
@@ -21,7 +21,7 @@ func TFTP() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
if controller.Warewulf.GrubBoot {
|
||||
if controller.Warewulf.GrubBoot() {
|
||||
err := warewulfd.CopyShimGrub()
|
||||
if err != nil {
|
||||
wwlog.Warn("error when copying shim/grub binaries: %s", err)
|
||||
@@ -43,7 +43,7 @@ func TFTP() (err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if !controller.TFTP.Enabled {
|
||||
if !controller.TFTP.Enabled() {
|
||||
wwlog.Warn("Warewulf does not auto start TFTP services due to disable by warewulf.conf")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ func InitMountPnts(binds []string) (mounts []*warewulfconf.MountEntry) {
|
||||
}
|
||||
}
|
||||
mntPnt := warewulfconf.MountEntry{
|
||||
Source: bind[0],
|
||||
Dest: dest,
|
||||
ReadOnly: readonly,
|
||||
Copy: copy_,
|
||||
Source: bind[0],
|
||||
Dest: dest,
|
||||
ReadOnlyP: &readonly,
|
||||
CopyP: ©_,
|
||||
}
|
||||
mounts = append(mounts, &mntPnt)
|
||||
}
|
||||
|
||||
@@ -75,30 +75,30 @@ func (this *WarewulfYaml) Upgrade() (upgraded *config.WarewulfYaml) {
|
||||
|
||||
type WarewulfConf struct {
|
||||
Port int `yaml:"port"`
|
||||
Secure bool `yaml:"secure"`
|
||||
Secure *bool `yaml:"secure"`
|
||||
UpdateInterval int `yaml:"update interval"`
|
||||
AutobuildOverlays bool `yaml:"autobuild overlays"`
|
||||
EnableHostOverlay bool `yaml:"host overlay"`
|
||||
Syslog bool `yaml:"syslog"`
|
||||
AutobuildOverlays *bool `yaml:"autobuild overlays"`
|
||||
EnableHostOverlay *bool `yaml:"host overlay"`
|
||||
Syslog *bool `yaml:"syslog"`
|
||||
DataStore string `yaml:"datastore"`
|
||||
GrubBoot bool `yaml:"grubboot"`
|
||||
GrubBoot *bool `yaml:"grubboot"`
|
||||
}
|
||||
|
||||
func (this *WarewulfConf) Upgrade() (upgraded *config.WarewulfConf) {
|
||||
upgraded = new(config.WarewulfConf)
|
||||
upgraded.Port = this.Port
|
||||
upgraded.Secure = this.Secure
|
||||
upgraded.SecureP = this.Secure
|
||||
upgraded.UpdateInterval = this.UpdateInterval
|
||||
upgraded.AutobuildOverlays = this.AutobuildOverlays
|
||||
upgraded.EnableHostOverlay = this.EnableHostOverlay
|
||||
upgraded.Syslog = this.Syslog
|
||||
upgraded.AutobuildOverlaysP = this.AutobuildOverlays
|
||||
upgraded.EnableHostOverlayP = this.EnableHostOverlay
|
||||
upgraded.SyslogP = this.Syslog
|
||||
upgraded.DataStore = this.DataStore
|
||||
upgraded.GrubBoot = this.GrubBoot
|
||||
upgraded.GrubBootP = this.GrubBoot
|
||||
return upgraded
|
||||
}
|
||||
|
||||
type DHCPConf struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Enabled *bool `yaml:"enabled"`
|
||||
Template string `yaml:"template"`
|
||||
RangeStart string `yaml:"range start"`
|
||||
RangeEnd string `yaml:"range end"`
|
||||
@@ -107,7 +107,7 @@ type DHCPConf struct {
|
||||
|
||||
func (this *DHCPConf) Upgrade() (upgraded *config.DHCPConf) {
|
||||
upgraded = new(config.DHCPConf)
|
||||
upgraded.Enabled = this.Enabled
|
||||
upgraded.EnabledP = this.Enabled
|
||||
upgraded.Template = this.Template
|
||||
upgraded.RangeStart = this.RangeStart
|
||||
upgraded.RangeEnd = this.RangeEnd
|
||||
@@ -116,7 +116,7 @@ func (this *DHCPConf) Upgrade() (upgraded *config.DHCPConf) {
|
||||
}
|
||||
|
||||
type TFTPConf struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Enabled *bool `yaml:"enabled"`
|
||||
TftpRoot string `yaml:"tftproot"`
|
||||
SystemdName string `yaml:"systemd name"`
|
||||
IpxeBinaries map[string]string `yaml:"ipxe"`
|
||||
@@ -124,7 +124,7 @@ type TFTPConf struct {
|
||||
|
||||
func (this *TFTPConf) Upgrade() (upgraded *config.TFTPConf) {
|
||||
upgraded = new(config.TFTPConf)
|
||||
upgraded.Enabled = this.Enabled
|
||||
upgraded.EnabledP = this.Enabled
|
||||
upgraded.TftpRoot = this.TftpRoot
|
||||
upgraded.SystemdName = this.SystemdName
|
||||
upgraded.IpxeBinaries = make(map[string]string)
|
||||
@@ -135,15 +135,21 @@ func (this *TFTPConf) Upgrade() (upgraded *config.TFTPConf) {
|
||||
}
|
||||
|
||||
type NFSConf struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Enabled *bool `yaml:"enabled"`
|
||||
Exports []string `yaml:"exports"`
|
||||
ExportsExtended []*NFSExportConf `yaml:"export paths"`
|
||||
SystemdName string `yaml:"systemd name"`
|
||||
}
|
||||
|
||||
func (this *NFSConf) Upgrade() (upgraded *config.NFSConf) {
|
||||
upgraded = new(config.NFSConf)
|
||||
upgraded.Enabled = this.Enabled
|
||||
upgraded.EnabledP = this.Enabled
|
||||
upgraded.ExportsExtended = make([]*config.NFSExportConf, 0)
|
||||
for _, export := range this.Exports {
|
||||
extendedExport := new(config.NFSExportConf)
|
||||
extendedExport.Path = export
|
||||
upgraded.ExportsExtended = append(upgraded.ExportsExtended, extendedExport)
|
||||
}
|
||||
for _, export := range this.ExportsExtended {
|
||||
upgraded.ExportsExtended = append(upgraded.ExportsExtended, export.Upgrade())
|
||||
}
|
||||
@@ -155,7 +161,7 @@ type NFSExportConf struct {
|
||||
Path string `yaml:"path"`
|
||||
ExportOptions string `yaml:"export options"`
|
||||
MountOptions string `yaml:"mount options"`
|
||||
Mount bool `yaml:"mount"`
|
||||
Mount *bool `yaml:"mount"`
|
||||
}
|
||||
|
||||
func (this *NFSExportConf) Upgrade() (upgraded *config.NFSExportConf) {
|
||||
@@ -163,7 +169,7 @@ func (this *NFSExportConf) Upgrade() (upgraded *config.NFSExportConf) {
|
||||
upgraded.Path = this.Path
|
||||
upgraded.ExportOptions = this.ExportOptions
|
||||
upgraded.MountOptions = this.MountOptions
|
||||
upgraded.Mount = this.Mount
|
||||
upgraded.MountP = this.Mount
|
||||
return upgraded
|
||||
}
|
||||
|
||||
@@ -180,18 +186,18 @@ func (this *SSHConf) Upgrade() (upgraded *config.SSHConf) {
|
||||
type MountEntry struct {
|
||||
Source string `yaml:"source"`
|
||||
Dest string `yaml:"dest"`
|
||||
ReadOnly bool `yaml:"readonly"`
|
||||
ReadOnly *bool `yaml:"readonly"`
|
||||
Options string `yaml:"options"`
|
||||
Copy bool `yaml:"copy"`
|
||||
Copy *bool `yaml:"copy"`
|
||||
}
|
||||
|
||||
func (this *MountEntry) Upgrade() (upgraded *config.MountEntry) {
|
||||
upgraded = new(config.MountEntry)
|
||||
upgraded.Source = this.Source
|
||||
upgraded.Dest = this.Dest
|
||||
upgraded.ReadOnly = this.ReadOnly
|
||||
upgraded.ReadOnlyP = this.ReadOnly
|
||||
upgraded.Options = this.Options
|
||||
upgraded.Copy = this.Copy
|
||||
upgraded.CopyP = this.Copy
|
||||
return upgraded
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ warewulf:
|
||||
port: 9873
|
||||
secure: true
|
||||
update interval: 60
|
||||
host overlay: false
|
||||
dhcp:
|
||||
enabled: true
|
||||
template: default
|
||||
@@ -61,7 +60,9 @@ tftp:
|
||||
tftproot: /var/lib/tftpboot
|
||||
systemd name: tftp
|
||||
nfs:
|
||||
enabled: false
|
||||
export paths:
|
||||
- path: /home
|
||||
- path: /var/warewulf
|
||||
systemd name: nfs-server
|
||||
`,
|
||||
},
|
||||
@@ -97,7 +98,6 @@ warewulf:
|
||||
port: 9873
|
||||
secure: true
|
||||
update interval: 60
|
||||
host overlay: false
|
||||
dhcp:
|
||||
enabled: true
|
||||
template: default
|
||||
@@ -109,7 +109,9 @@ tftp:
|
||||
tftproot: /var/lib/tftpboot
|
||||
systemd name: tftp
|
||||
nfs:
|
||||
enabled: false
|
||||
export paths:
|
||||
- path: /home
|
||||
- path: /var/warewulf
|
||||
systemd name: nfs-server
|
||||
`,
|
||||
},
|
||||
@@ -148,7 +150,7 @@ warewulf:
|
||||
secure: true
|
||||
update interval: 60
|
||||
autobuild overlays: true
|
||||
host overlay: false
|
||||
syslog: false
|
||||
dhcp:
|
||||
enabled: true
|
||||
template: default
|
||||
@@ -160,7 +162,9 @@ tftp:
|
||||
tftproot: /var/lib/tftpboot
|
||||
systemd name: tftp
|
||||
nfs:
|
||||
enabled: false
|
||||
export paths:
|
||||
- path: /home
|
||||
- path: /var/warewulf
|
||||
systemd name: nfs-server
|
||||
`,
|
||||
},
|
||||
@@ -212,6 +216,7 @@ warewulf:
|
||||
update interval: 60
|
||||
autobuild overlays: true
|
||||
host overlay: true
|
||||
syslog: false
|
||||
dhcp:
|
||||
enabled: true
|
||||
template: default
|
||||
@@ -280,6 +285,7 @@ warewulf:
|
||||
update interval: 60
|
||||
autobuild overlays: true
|
||||
host overlay: true
|
||||
syslog: false
|
||||
dhcp:
|
||||
enabled: true
|
||||
range start: 192.168.200.50
|
||||
@@ -362,6 +368,7 @@ warewulf:
|
||||
update interval: 60
|
||||
autobuild overlays: true
|
||||
host overlay: true
|
||||
syslog: false
|
||||
dhcp:
|
||||
enabled: true
|
||||
range start: 10.0.1.1
|
||||
|
||||
@@ -18,6 +18,10 @@ import (
|
||||
"github.com/warewulf/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
|
||||
func BoolP(p *bool) bool {
|
||||
return p != nil && *p
|
||||
}
|
||||
|
||||
func FirstError(errs ...error) (err error) {
|
||||
for _, e := range errs {
|
||||
if err == nil {
|
||||
|
||||
@@ -57,7 +57,7 @@ func DaemonInitLogging() error {
|
||||
|
||||
conf := warewulfconf.Get()
|
||||
|
||||
if conf.Warewulf.Syslog {
|
||||
if conf.Warewulf.Syslog() {
|
||||
|
||||
wwlog.Debug("Changing log output to syslog")
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
wwlog.Info("request from hwaddr:%s ipaddr:%s | stage:%s", rinfo.hwaddr, req.RemoteAddr, rinfo.stage)
|
||||
|
||||
if (rinfo.stage == "runtime" || len(rinfo.overlay) > 0) && conf.Warewulf.Secure {
|
||||
if (rinfo.stage == "runtime" || len(rinfo.overlay) > 0) && conf.Warewulf.Secure() {
|
||||
if rinfo.remoteport >= 1024 {
|
||||
wwlog.Denied("Non-privileged port: %s", req.RemoteAddr)
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
@@ -149,7 +149,7 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
|
||||
remoteNode,
|
||||
context,
|
||||
request_overlays,
|
||||
conf.Warewulf.AutobuildOverlays)
|
||||
conf.Warewulf.AutobuildOverlays())
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, overlay.ErrDoesNotExist) {
|
||||
|
||||
@@ -101,7 +101,8 @@ nodes:
|
||||
dbErr := LoadNodeDB()
|
||||
assert.NoError(t, dbErr)
|
||||
|
||||
conf.Warewulf.Secure = false
|
||||
secureFalse := false
|
||||
conf.Warewulf.SecureP = &secureFalse
|
||||
assert.NoError(t, os.MkdirAll(path.Join(conf.Paths.OverlayProvisiondir(), "n1"), 0700))
|
||||
assert.NoError(t, os.WriteFile(path.Join(conf.Paths.OverlayProvisiondir(), "n1", "__SYSTEM__.img"), []byte("system overlay"), 0600))
|
||||
assert.NoError(t, os.WriteFile(path.Join(conf.Paths.OverlayProvisiondir(), "n1", "__RUNTIME__.img"), []byte("runtime overlay"), 0600))
|
||||
|
||||
Reference in New Issue
Block a user