Update wwctl upgrade to manage TLS configuration
Also fixed an omission for API configuration in wwctl upgrade. Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Include api configuration during `wwctl upgrade config`
|
||||||
- Prevent `assetkey` from leaking into wwclient logs.
|
- Prevent `assetkey` from leaking into wwclient logs.
|
||||||
- Remove requisite dependency between ignition disk target and ignition service. #2083
|
- Remove requisite dependency between ignition disk target and ignition service. #2083
|
||||||
- Return HTTP 409 status when creating an existing overlay
|
- Return HTTP 409 status when creating an existing overlay
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
|||||||
port := conf.Warewulf.Port
|
port := conf.Warewulf.Port
|
||||||
scheme := "http"
|
scheme := "http"
|
||||||
if conf.Warewulf.TLSEnabled() {
|
if conf.Warewulf.TLSEnabled() {
|
||||||
port = conf.Warewulf.TlsPort
|
port = conf.Warewulf.TLSPort
|
||||||
scheme = "https"
|
scheme = "https"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func (conf TFTPConf) Enabled() bool {
|
|||||||
// BaseConf.
|
// BaseConf.
|
||||||
type WarewulfConf struct {
|
type WarewulfConf struct {
|
||||||
Port int `yaml:"port,omitempty" default:"9873"`
|
Port int `yaml:"port,omitempty" default:"9873"`
|
||||||
TlsPort int `yaml:"tls port,omitempty" default:"9874"`
|
TLSPort int `yaml:"tls port,omitempty" default:"9874"`
|
||||||
SecureP *bool `yaml:"secure,omitempty" default:"true"`
|
SecureP *bool `yaml:"secure,omitempty" default:"true"`
|
||||||
TLSEnabledP *bool `yaml:"tls,omitempty"`
|
TLSEnabledP *bool `yaml:"tls,omitempty"`
|
||||||
UpdateInterval int `yaml:"update interval,omitempty" default:"60"`
|
UpdateInterval int `yaml:"update interval,omitempty" default:"60"`
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type WarewulfYaml struct {
|
|||||||
Ipv6net string `yaml:"ipv6net"`
|
Ipv6net string `yaml:"ipv6net"`
|
||||||
Fqdn string `yaml:"fqdn"`
|
Fqdn string `yaml:"fqdn"`
|
||||||
Warewulf *WarewulfConf `yaml:"warewulf"`
|
Warewulf *WarewulfConf `yaml:"warewulf"`
|
||||||
|
API *APIConf `yaml:"api"`
|
||||||
DHCP *DHCPConf `yaml:"dhcp"`
|
DHCP *DHCPConf `yaml:"dhcp"`
|
||||||
TFTP *TFTPConf `yaml:"tftp"`
|
TFTP *TFTPConf `yaml:"tftp"`
|
||||||
NFS *NFSConf `yaml:"nfs"`
|
NFS *NFSConf `yaml:"nfs"`
|
||||||
@@ -52,6 +53,9 @@ func (legacy *WarewulfYaml) Upgrade() (upgraded *config.WarewulfYaml) {
|
|||||||
if legacy.Warewulf != nil {
|
if legacy.Warewulf != nil {
|
||||||
upgraded.Warewulf = legacy.Warewulf.Upgrade()
|
upgraded.Warewulf = legacy.Warewulf.Upgrade()
|
||||||
}
|
}
|
||||||
|
if legacy.API != nil {
|
||||||
|
upgraded.API = legacy.API.Upgrade()
|
||||||
|
}
|
||||||
if legacy.DHCP != nil {
|
if legacy.DHCP != nil {
|
||||||
upgraded.DHCP = legacy.DHCP.Upgrade()
|
upgraded.DHCP = legacy.DHCP.Upgrade()
|
||||||
}
|
}
|
||||||
@@ -92,7 +96,9 @@ func (legacy *WarewulfYaml) Upgrade() (upgraded *config.WarewulfYaml) {
|
|||||||
|
|
||||||
type WarewulfConf struct {
|
type WarewulfConf struct {
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port"`
|
||||||
|
TLSPort int `yaml:"tls port"`
|
||||||
Secure *bool `yaml:"secure"`
|
Secure *bool `yaml:"secure"`
|
||||||
|
TLSEnabled *bool `yaml:"tls"`
|
||||||
UpdateInterval int `yaml:"update interval"`
|
UpdateInterval int `yaml:"update interval"`
|
||||||
AutobuildOverlays *bool `yaml:"autobuild overlays"`
|
AutobuildOverlays *bool `yaml:"autobuild overlays"`
|
||||||
EnableHostOverlay *bool `yaml:"host overlay"`
|
EnableHostOverlay *bool `yaml:"host overlay"`
|
||||||
@@ -105,7 +111,9 @@ type WarewulfConf struct {
|
|||||||
func (legacy *WarewulfConf) Upgrade() (upgraded *config.WarewulfConf) {
|
func (legacy *WarewulfConf) Upgrade() (upgraded *config.WarewulfConf) {
|
||||||
upgraded = new(config.WarewulfConf)
|
upgraded = new(config.WarewulfConf)
|
||||||
upgraded.Port = legacy.Port
|
upgraded.Port = legacy.Port
|
||||||
|
upgraded.TLSPort = legacy.TLSPort
|
||||||
upgraded.SecureP = legacy.Secure
|
upgraded.SecureP = legacy.Secure
|
||||||
|
upgraded.TLSEnabledP = legacy.TLSEnabled
|
||||||
upgraded.UpdateInterval = legacy.UpdateInterval
|
upgraded.UpdateInterval = legacy.UpdateInterval
|
||||||
upgraded.AutobuildOverlaysP = legacy.AutobuildOverlays
|
upgraded.AutobuildOverlaysP = legacy.AutobuildOverlays
|
||||||
upgraded.EnableHostOverlayP = legacy.EnableHostOverlay
|
upgraded.EnableHostOverlayP = legacy.EnableHostOverlay
|
||||||
@@ -117,6 +125,20 @@ func (legacy *WarewulfConf) Upgrade() (upgraded *config.WarewulfConf) {
|
|||||||
return upgraded
|
return upgraded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type APIConf struct {
|
||||||
|
Enabled *bool `yaml:"enabled"`
|
||||||
|
TLSEnabled *bool `yaml:"tls"`
|
||||||
|
AllowedNets []config.IPNet `yaml:"allowed subnets"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (legacy *APIConf) Upgrade() (upgraded *config.APIConf) {
|
||||||
|
upgraded = new(config.APIConf)
|
||||||
|
upgraded.EnabledP = legacy.Enabled
|
||||||
|
upgraded.TLSEnabledP = legacy.TLSEnabled
|
||||||
|
upgraded.AllowedNets = append([]config.IPNet{}, legacy.AllowedNets...)
|
||||||
|
return upgraded
|
||||||
|
}
|
||||||
|
|
||||||
type DHCPConf struct {
|
type DHCPConf struct {
|
||||||
Enabled *bool `yaml:"enabled"`
|
Enabled *bool `yaml:"enabled"`
|
||||||
Template string `yaml:"template"`
|
Template string `yaml:"template"`
|
||||||
|
|||||||
@@ -580,6 +580,63 @@ image mounts:
|
|||||||
readonly: true
|
readonly: true
|
||||||
paths:
|
paths:
|
||||||
datadir: /usr/share
|
datadir: /usr/share
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "v4.6.5-tls",
|
||||||
|
legacyYaml: `
|
||||||
|
ipaddr: 10.0.0.1
|
||||||
|
netmask: 255.255.252.0
|
||||||
|
network: 10.0.0.0
|
||||||
|
warewulf:
|
||||||
|
port: 9873
|
||||||
|
tls port: 9874
|
||||||
|
secure: true
|
||||||
|
tls: true
|
||||||
|
update interval: 60
|
||||||
|
autobuild overlays: true
|
||||||
|
host overlay: true
|
||||||
|
api:
|
||||||
|
enabled: true
|
||||||
|
tls: true
|
||||||
|
allowed subnets:
|
||||||
|
- 127.0.0.0/8
|
||||||
|
- ::1/128
|
||||||
|
dhcp:
|
||||||
|
enabled: true
|
||||||
|
range start: 10.0.1.1
|
||||||
|
range end: 10.0.1.255
|
||||||
|
systemd name: dhcpd
|
||||||
|
tftp:
|
||||||
|
enabled: true
|
||||||
|
systemd name: tftp
|
||||||
|
`,
|
||||||
|
upgradedYaml: `
|
||||||
|
ipaddr: 10.0.0.1
|
||||||
|
netmask: 255.255.252.0
|
||||||
|
network: 10.0.0.0
|
||||||
|
warewulf:
|
||||||
|
port: 9873
|
||||||
|
tls port: 9874
|
||||||
|
secure: true
|
||||||
|
tls: true
|
||||||
|
update interval: 60
|
||||||
|
autobuild overlays: true
|
||||||
|
host overlay: true
|
||||||
|
api:
|
||||||
|
enabled: true
|
||||||
|
tls: true
|
||||||
|
allowed subnets:
|
||||||
|
- 127.0.0.0/8
|
||||||
|
- ::1/128
|
||||||
|
dhcp:
|
||||||
|
enabled: true
|
||||||
|
range start: 10.0.1.1
|
||||||
|
range end: 10.0.1.255
|
||||||
|
systemd name: dhcpd
|
||||||
|
tftp:
|
||||||
|
enabled: true
|
||||||
|
systemd name: tftp
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ func RunServer() error {
|
|||||||
}
|
}
|
||||||
httpsHandler := configureRootHandler(apiHandler)
|
httpsHandler := configureRootHandler(apiHandler)
|
||||||
go func() {
|
go func() {
|
||||||
wwlog.Info("Starting HTTPS service on port %d", conf.Warewulf.TlsPort)
|
wwlog.Info("Starting HTTPS service on port %d", conf.Warewulf.TLSPort)
|
||||||
if err := http.ListenAndServeTLS(":"+strconv.Itoa(conf.Warewulf.TlsPort), crt, key, httpsHandler); err != nil {
|
if err := http.ListenAndServeTLS(":"+strconv.Itoa(conf.Warewulf.TLSPort), crt, key, httpsHandler); err != nil {
|
||||||
errChan <- fmt.Errorf("could not start HTTPS service: %w", err)
|
errChan <- fmt.Errorf("could not start HTTPS service: %w", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ WWIPMI_WRITE="{{$.Ipmi.Write.Bool}}"
|
|||||||
WWIPMI_VLAN="{{$.Ipmi.Tags.vlan}}"
|
WWIPMI_VLAN="{{$.Ipmi.Tags.vlan}}"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
WWTLS={{$.Warewulf.TLSEnabled}}
|
WWTLS={{$.Warewulf.TLSEnabled}}
|
||||||
WWTLSPORT={{$.Warewulf.TlsPort}}
|
WWTLSPORT={{$.Warewulf.TLSPort}}
|
||||||
WWIPADDR={{$.Ipaddr}}
|
WWIPADDR={{$.Ipaddr}}
|
||||||
|
|||||||
Reference in New Issue
Block a user