diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f5aac3e..f33146fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Support If-None-Match header in `PUT /api/nodes/{id}` - Added `PUT|DELETE /api/overlays/{name}/file?path={path}` - Added `DELETE /api/overlays/{name}/file?path={path}` +- Added `wwctl configure warewulfd` ### Changed @@ -24,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fixed a bug when cloning an overlay to site when parent is missing - Fixed `wwctl upgrade nodes` to properly handle kernel argument lists. #1938 +- Improved netplan support. #1873 ## v4.6.2, 2025-07-09 diff --git a/internal/app/wwctl/configure/main.go b/internal/app/wwctl/configure/main.go index 090a2353..2d594729 100644 --- a/internal/app/wwctl/configure/main.go +++ b/internal/app/wwctl/configure/main.go @@ -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 { diff --git a/internal/app/wwctl/configure/root.go b/internal/app/wwctl/configure/root.go index 3abd0776..cdacd64d 100644 --- a/internal/app/wwctl/configure/root.go +++ b/internal/app/wwctl/configure/root.go @@ -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") } diff --git a/internal/app/wwctl/configure/warewulfd/main.go b/internal/app/wwctl/configure/warewulfd/main.go new file mode 100644 index 00000000..08eb0aa9 --- /dev/null +++ b/internal/app/wwctl/configure/warewulfd/main.go @@ -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() +} diff --git a/internal/app/wwctl/configure/warewulfd/root.go b/internal/app/wwctl/configure/warewulfd/root.go new file mode 100644 index 00000000..5fea22da --- /dev/null +++ b/internal/app/wwctl/configure/warewulfd/root.go @@ -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 +} diff --git a/internal/pkg/config/buildconfig.go.in b/internal/pkg/config/buildconfig.go.in index 6e442d34..8896d30e 100644 --- a/internal/pkg/config/buildconfig.go.in +++ b/internal/pkg/config/buildconfig.go.in @@ -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 { diff --git a/internal/pkg/configure/warewulfd.go b/internal/pkg/configure/warewulfd.go new file mode 100644 index 00000000..e24764eb --- /dev/null +++ b/internal/pkg/configure/warewulfd.go @@ -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 +} diff --git a/internal/pkg/upgrade/config.go b/internal/pkg/upgrade/config.go index 212410e8..65fc2803 100644 --- a/internal/pkg/upgrade/config.go +++ b/internal/pkg/upgrade/config.go @@ -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 } diff --git a/internal/pkg/upgrade/config_test.go b/internal/pkg/upgrade/config_test.go index d9e5470b..90868a67 100644 --- a/internal/pkg/upgrade/config_test.go +++ b/internal/pkg/upgrade/config_test.go @@ -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 `, }, }