added warewuld configure option

Co-authored-by: Jonathon Anderson <janderson@ciq.com>
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Christian Goll
2025-07-25 15:53:17 +02:00
committed by Jonathon Anderson
parent f2d06d5928
commit 2c51ca7fff
9 changed files with 174 additions and 16 deletions

View File

@@ -20,33 +20,32 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if allFunctions {
err = configure.WAREWULFD()
if err != nil {
return err
}
err = configure.DHCP()
if err != nil {
wwlog.Error("%s", err)
os.Exit(1)
return err
}
err = configure.NFS()
if err != nil {
wwlog.Error("%s", err)
os.Exit(1)
return err
}
err = configure.SSH(warewulfconf.Get().SSH.KeyTypes...)
if err != nil {
wwlog.Error("%s", err)
os.Exit(1)
return err
}
err = configure.TFTP()
if err != nil {
wwlog.Error("%s", err)
os.Exit(1)
return err
}
err = configure.Hostfile()
if err != nil {
wwlog.Error("%s", err)
os.Exit(1)
return err
}
} else {

View File

@@ -7,6 +7,7 @@ import (
"github.com/warewulf/warewulf/internal/app/wwctl/configure/nfs"
"github.com/warewulf/warewulf/internal/app/wwctl/configure/ssh"
"github.com/warewulf/warewulf/internal/app/wwctl/configure/tftp"
"github.com/warewulf/warewulf/internal/app/wwctl/configure/warewulfd"
)
var (
@@ -28,6 +29,7 @@ func init() {
baseCmd.AddCommand(ssh.GetCommand())
baseCmd.AddCommand(nfs.GetCommand())
baseCmd.AddCommand(hostfile.GetCommand())
baseCmd.AddCommand(warewulfd.GetCommand())
baseCmd.Flags().BoolVarP(&allFunctions, "all", "a", false, "Configure all services")
}

View File

@@ -0,0 +1,10 @@
package warewulfd
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/pkg/configure"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
return configure.WAREWULFD()
}

View File

@@ -0,0 +1,23 @@
package warewulfd
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
var (
baseCmd = &cobra.Command{
DisableFlagsInUseLine: true,
Use: "warewulfd [OPTIONS]",
Short: "Enable and start warewulfd",
Long: "Enable and starts the warewulfd service.",
RunE: CobraRunE,
Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
}
)
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd
}

View File

@@ -40,12 +40,13 @@ func (conf TFTPConf) Enabled() bool {
// WarewulfConf adds additional Warewulf-specific configuration to
// BaseConf.
type WarewulfConf struct {
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"`
GrubBootP *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"`
GrubBootP *bool `yaml:"grubboot,omitempty" default:"false"`
SystemdName string `yaml:"systemd name,omitempty"`
}
func (conf WarewulfConf) Secure() bool {

View File

@@ -0,0 +1,22 @@
package configure
import (
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/util"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
)
func WAREWULFD() (err error) {
controller := warewulfconf.Get()
if controller.Warewulf.SystemdName != "" {
wwlog.Info("Enabling and restarting the Warewulf server")
err = util.SystemdStart(controller.Warewulf.SystemdName)
if err != nil {
return err
}
} else {
wwlog.Warn("Not (re)starting Warewulf server: no systemd name configured")
}
return nil
}

View File

@@ -97,6 +97,7 @@ type WarewulfConf struct {
Syslog *bool `yaml:"syslog"`
DataStore string `yaml:"datastore"`
GrubBoot *bool `yaml:"grubboot"`
SystemdName string `yaml:"systemd name"`
}
func (legacy *WarewulfConf) Upgrade() (upgraded *config.WarewulfConf) {
@@ -110,6 +111,7 @@ func (legacy *WarewulfConf) Upgrade() (upgraded *config.WarewulfConf) {
wwlog.Warn("syslog configuration ignored: all logs now go to stdout/stderr")
}
upgraded.GrubBootP = legacy.GrubBoot
upgraded.SystemdName = legacy.SystemdName
return upgraded
}

View File

@@ -483,6 +483,103 @@ image mounts:
readonly: true
paths:
datadir: /usr/share
`,
},
{
name: "v4.6.3",
legacyYaml: `
ipaddr: 10.0.0.1
netmask: 255.255.252.0
network: 10.0.0.0
warewulf:
port: 9873
secure: false
update interval: 60
autobuild overlays: true
host overlay: true
syslog: false
datastore: /usr/share
systemd name: warewulfd
dhcp:
enabled: true
range start: 10.0.1.1
range end: 10.0.1.255
systemd name: dhcpd
tftp:
enabled: true
systemd name: tftp
ipxe:
00:0B: arm64-efi/snponly.efi
"00:00": undionly.kpxe
"00:07": ipxe-snponly-x86_64.efi
"00:09": ipxe-snponly-x86_64.efi
nfs:
enabled: true
export paths:
- path: /home
export options: rw,sync
mount options: defaults
mount: true
- path: /opt
export options: ro,sync,no_root_squash
mount options: defaults
mount: false
systemd name: nfs-server
ssh:
key types:
- rsa
- dsa
- ecdsa
- ed25519
container mounts:
- source: /etc/resolv.conf
dest: /etc/resolv.conf
readonly: true
`,
upgradedYaml: `
ipaddr: 10.0.0.1
netmask: 255.255.252.0
network: 10.0.0.0
warewulf:
port: 9873
secure: false
update interval: 60
autobuild overlays: true
host overlay: true
systemd name: warewulfd
dhcp:
enabled: true
range start: 10.0.1.1
range end: 10.0.1.255
systemd name: dhcpd
tftp:
enabled: true
systemd name: tftp
ipxe:
00:0B: arm64-efi/snponly.efi
"00:00": undionly.kpxe
"00:07": ipxe-snponly-x86_64.efi
"00:09": ipxe-snponly-x86_64.efi
nfs:
enabled: true
export paths:
- path: /home
export options: rw,sync
- path: /opt
export options: ro,sync,no_root_squash
systemd name: nfs-server
ssh:
key types:
- rsa
- dsa
- ecdsa
- ed25519
image mounts:
- source: /etc/resolv.conf
dest: /etc/resolv.conf
readonly: true
paths:
datadir: /usr/share
`,
},
}