From 9fdb9ca792a7e35eac9276d1e40f77a2c040985f Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Wed, 17 Jul 2024 15:30:51 +0200 Subject: [PATCH] updated overlays Signed-off-by: Christian Goll --- etc/nodes.conf | 13 ++++++++++++- internal/pkg/node/modifiers.go | 2 +- .../system-connections/ww4-managed.ww | 4 ++-- .../debug/rootfs/warewulf/template-variables.md.ww | 2 -- overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww | 14 +++++++------- .../host/rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww | 6 +++--- overlays/host/rootfs/etc/hosts.ww | 10 +++++----- overlays/issue/rootfs/etc/issue.ww | 12 ++++++++---- .../wicked/rootfs/etc/wicked/ifconfig/ifcfg.xml.ww | 2 +- userdocs/contents/templating.rst | 12 ++++++------ 10 files changed, 45 insertions(+), 32 deletions(-) diff --git a/etc/nodes.conf b/etc/nodes.conf index 4dd95e03..c77052e2 100644 --- a/etc/nodes.conf +++ b/etc/nodes.conf @@ -1,5 +1,16 @@ -WW_INTERNAL: 45 +WW_INTERNAL: 46 nodeprofiles: default: comment: This profile is automatically included for each node + runtime overlay: + - generic + system overlay: + - wwinit + kernel: + args: quiet crashkernel=no + init: /sbin/init + root: initramfs + ipxe template: default + profiles: + - default nodes: {} diff --git a/internal/pkg/node/modifiers.go b/internal/pkg/node/modifiers.go index 0efef3ff..6abf88a1 100644 --- a/internal/pkg/node/modifiers.go +++ b/internal/pkg/node/modifiers.go @@ -81,7 +81,7 @@ func (config *NodeYaml) SetProfile(profileId string, vals ProfileConf) error { Add a node with the given ID and return a pointer to it */ func (config *NodeYaml) AddProfile(profileId string) (*ProfileConf, error) { - profile := NewProfile(profileId) + profile := EmptyProfile() wwlog.Verbose("adding new profile: %s", profileId) if _, ok := config.nodeProfiles[profileId]; ok { return nil, errors.New("profile already exists: " + profileId) diff --git a/overlays/NetworkManager/rootfs/etc/NetworkManager/system-connections/ww4-managed.ww b/overlays/NetworkManager/rootfs/etc/NetworkManager/system-connections/ww4-managed.ww index cb7e2bc6..88172091 100644 --- a/overlays/NetworkManager/rootfs/etc/NetworkManager/system-connections/ww4-managed.ww +++ b/overlays/NetworkManager/rootfs/etc/NetworkManager/system-connections/ww4-managed.ww @@ -52,9 +52,9 @@ mtu={{ $netdev.MTU }} {{ end -}} {{ end -}} -{{ if and ($netdev.IpCIDR) (ne $netdev.Type "bond-slave") -}} +{{ if and ($netdev.Ipaddr) (ne $netdev.Type "bond-slave") -}} [ipv4] -address={{ $netdev.IpCIDR }} +address={{ $netdev.Ipaddr }} {{ if $netdev.Gateway -}} gateway={{ $netdev.Gateway }} {{ end -}} diff --git a/overlays/debug/rootfs/warewulf/template-variables.md.ww b/overlays/debug/rootfs/warewulf/template-variables.md.ww index dcd4708a..2bdbeb2e 100644 --- a/overlays/debug/rootfs/warewulf/template-variables.md.ww +++ b/overlays/debug/rootfs/warewulf/template-variables.md.ww @@ -51,7 +51,6 @@ data from other structures. - Device: {{ $netdev.Device }} - Hwaddr: {{ $netdev.Hwaddr }} - Ipaddr: {{ $netdev.Ipaddr }} - - IpCIDR: {{ $netdev.IpCIDR }} - Ipaddr6: {{ $netdev.Ipaddr6 }} - Prefix: {{ $netdev.Prefix }} - Netmask: {{ $netdev.Netmask }} @@ -165,7 +164,6 @@ data from other structures. - Hwaddr: {{ $netdev.Hwaddr.Get }} - Ipaddr: {{ $netdev.Ipaddr.Get }} - Ipaddr6: {{ $netdev.Ipaddr6.Get }} - - IpCIDR: {{ $netdev.IpCIDR.Get }} - Prefix: {{ $netdev.Prefix.Get }} - Netmask: {{ $netdev.Netmask.Get }} - Gateway: {{ $netdev.Gateway.Get }} diff --git a/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww b/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww index 04282f19..386ab842 100644 --- a/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww +++ b/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww @@ -57,16 +57,16 @@ subnet {{$.Network}} netmask {{$.Netmask}} { {{- if eq .Dhcp.Template "static" }} {{- range $nodes := $.AllNodes}} {{- range $netname, $netdevs := $nodes.NetDevs}} -host {{$nodes.Id.Get}}-{{$netname}} +host {{$nodes.Id}}-{{$netname}} { - {{- if $netdevs.Hwaddr.Defined}} - hardware ethernet {{$netdevs.Hwaddr.Get}}; + {{- if $netdevs.Hwaddr}} + hardware ethernet {{$netdevs.Hwaddr}}; {{- end }} - {{- if $netdevs.Ipaddr.Defined}} - fixed-address {{$netdevs.Ipaddr.Get}}; + {{- if $netdevs.Ipaddr}} + fixed-address {{$netdevs.Ipaddr}}; {{- end }} - {{- if $netdevs.Primary.GetB}} - option host-name "{{$nodes.Id.Get}}"; + {{- if $netdevs.Primary}} + option host-name "{{$nodes.Id}}"; {{- end }} } {{end -}}{{/* range NetDevs */}} diff --git a/overlays/host/rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww b/overlays/host/rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww index 01233e65..d8610406 100644 --- a/overlays/host/rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww +++ b/overlays/host/rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww @@ -35,9 +35,9 @@ dhcp-range={{$.Dhcp.RangeStart}},{{$.Dhcp.RangeEnd}},{{$.Netmask}},6h {{/* Add all the known hosts */}} {{- range $node := $.AllNodes}} {{/* for each node */}} {{- range $devname, $netdev := $node.NetDevs}} {{/* for each network device on the node */}} -{{- if $netdev.Ipaddr.Defined}} {{/* if we have an ip address on this network device */}} -{{- if $netdev.Hwaddr.Defined }} -dhcp-host={{$netdev.Hwaddr.Get}},set:warewulf,{{$node.Id.Get}},{{$netdev.Ipaddr.Get}},infinite +{{- if $netdev.Ipaddr}} {{/* if we have an ip address on this network device */}} +{{- if $netdev.Hwaddr }} +dhcp-host={{$netdev.Hwaddr}},set:warewulf,{{$node.Id}},{{$netdev.Ipaddr}},infinite {{- end}}{{/* end if Hwaddr */}} {{- end}}{{/* end if ip */}} {{- end}}{{/* end for each network device */}} diff --git a/overlays/host/rootfs/etc/hosts.ww b/overlays/host/rootfs/etc/hosts.ww index 8b5a4d90..adda3c05 100644 --- a/overlays/host/rootfs/etc/hosts.ww +++ b/overlays/host/rootfs/etc/hosts.ww @@ -5,12 +5,12 @@ # Warewulf Server {{$.Ipaddr}} {{$.BuildHost}} warewulf -{{- range $node := $.AllNodes }}{{/* for each node */}} -# Entry for {{ $node.Id.Get }} -{{- range $devname, $netdev := $node.NetDevs }}{{/* for each network device on the node */}} -{{- if $netdev.Ipaddr.Defined }}{{/* if we have an ip address on this network device */}} +{{- range $node := $.AllNodes}} {{/* for each node */}} +# Entry for {{$node.Id}} +{{- range $devname, $netdev := $node.NetDevs}} {{/* for each network device on the node */}} +{{- if $netdev.Ipaddr}} {{/* if we have an ip address on this network device */}} {{- /* emit the node name as hostname if this is the primary */}} -{{$netdev.Ipaddr.Get}} {{if $netdev.Primary.GetB}}{{$node.Id.Get}}{{end}} {{$node.Id.Get}}-{{$devname}} {{if $netdev.Device.Defined}}{{$node.Id.Get}}-{{$netdev.Device.Get}}{{end}} +{{$netdev.Ipaddr}} {{if $netdev.Primary}}{{$node.Id}}{{end}} {{$node.Id}}-{{$devname}} {{if $netdev.Device}}{{$node.Id}}-{{$netdev.Device}}{{end}} {{- end }}{{/* if ip */}} {{- end }}{{/* for each network device */}} {{- end }}{{/* for each node */}} diff --git a/overlays/issue/rootfs/etc/issue.ww b/overlays/issue/rootfs/etc/issue.ww index d526a2b6..f7cd4e86 100644 --- a/overlays/issue/rootfs/etc/issue.ww +++ b/overlays/issue/rootfs/etc/issue.ww @@ -6,7 +6,11 @@ Kernelargs: {{.Kernel.Args}} Network: {{- range $devname, $netdev := .NetDevs}} {{$devname}}: {{$netdev.Device}} - {{$devname}}: {{$netdev.IpCIDR}} -{{if $netdev.Ipaddr6 }} {{$devname}}: {{$netdev.Ipaddr6}}{{ end -}} -{{if $netdev.Hwaddr }} {{$devname}}: {{$netdev.Hwaddr}}{{ end -}} -{{end}} + {{$devname}}: \4{{ print "{" }}{{$netdev.Device}}{{ print "}" }} +{{- if $netdev.Ipaddr6 }} + {{$devname}}: \6{{ print "{" }}{{$netdev.Device}}{{ print "}" }} +{{- end }} +{{- if $netdev.Hwaddr }} + {{$devname}}: {{$netdev.Hwaddr}} +{{- end }} +{{- end}} diff --git a/overlays/wicked/rootfs/etc/wicked/ifconfig/ifcfg.xml.ww b/overlays/wicked/rootfs/etc/wicked/ifconfig/ifcfg.xml.ww index 82573fdd..4b456a74 100644 --- a/overlays/wicked/rootfs/etc/wicked/ifconfig/ifcfg.xml.ww +++ b/overlays/wicked/rootfs/etc/wicked/ifconfig/ifcfg.xml.ww @@ -24,7 +24,7 @@ This file is autogenerated by warewulf
- {{ (index $NetDevs $devname).IpCIDR }} + {{$netdev.Ipaddr}}/{{$netdev.Ipmask}}
{{ if $netdev.Gateway.Get -}} diff --git a/userdocs/contents/templating.rst b/userdocs/contents/templating.rst index 51b18753..90420acd 100644 --- a/userdocs/contents/templating.rst +++ b/userdocs/contents/templating.rst @@ -110,7 +110,7 @@ The following template will create a file called
- {{$netdev.IpCIDR}} + {{$netdev.Ipaddr}}/{{$netdev.Ipmask}}
{{ if $netdev.Gateway -}} @@ -177,13 +177,13 @@ string is "# Do not edit after this line" {{$.Ipaddr}} warewulf {{$.BuildHost}} {{- range $node := $.AllNodes}} {{/* for each node */}} - # Entry for {{$node.Id.Get}} + # Entry for {{$node.Id}} {{- range $devname, $netdev := $node.NetDevs}} {{/* for each network device on the node */}} - {{- if $netdev.Ipaddr.Defined}} {{/* if we have an ip address on this network device */}} + {{- if $netdev.Ipaddr}} {{/* if we have an ip address on this network device */}} {{- /* emit the node name as hostname if this is the primary */}} - {{$netdev.Ipaddr.Get}} {{$node.Id.Get}}-{{$devname}} - {{- if $netdev.Device.Defined}} {{$node.Id.Get}}-{{$netdev.Device.Get}}{{end}} - {{- if $netdev.Primary.GetB}} {{$node.Id.Get}}{{end}} + {{$netdev.Ipaddr}} {{$node.Id}}-{{$devname}} + {{- if $netdev.Device}} {{$node.Id()}}-{{$netdev.Device}}{{end}} + {{- if $netdev.Primary}} {{$node.Id()}}{{end}} {{- end}} {{/* end if ip */}} {{- end}} {{/* end for each network device */}} {{- end}} {{/* end for each node */}}