Update network interface bonding configuration and documentation

- Closes: #1482
- Closes: #1280

This also corrects poor handling of whitespace around the "file" function
throughout the templates, given experiences with the network templates while
implementing the bond behavior. Since the file function actually does produce
output (that is parsed by Warewulf itself) it should not collaps prefix
whitespace.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-01-20 19:50:29 -07:00
parent 409b7269a7
commit c209dadc1f
20 changed files with 103 additions and 88 deletions

View File

@@ -95,6 +95,7 @@ unmanaged-devices=except:mac:e6:92:39:49:7b:03,except:interface-name:wwnet0,exce
const networkmanager_managed string = `backupFile: true
writeFile: true
Filename: warewulf-default.conf
# This file is autogenerated by warewulf
[connection]
@@ -102,14 +103,12 @@ id=default
interface-name=wwnet0
type=ethernet
autoconnect=true
[ethernet]
mac-address=e6:92:39:49:7b:03
[ipv4]
method=manual
address=192.168.3.21/24
gateway=192.168.3.1
method=manual
[ipv6]
addr-gen-mode=stable-privacy
@@ -125,14 +124,12 @@ id=secondary
interface-name=wwnet1
type=ethernet
autoconnect=true
[ethernet]
mac-address=9a:77:29:73:14:f1
[ipv4]
method=manual
address=192.168.3.22/24
gateway=192.168.3.1
method=manual
dns=8.8.8.8;8.8.4.4;
[ipv6]
@@ -144,6 +141,7 @@ never-default=true
const networkmanager_managed_with_vlan string = `backupFile: true
writeFile: true
Filename: warewulf-tagged.conf
# This file is autogenerated by warewulf
[connection]
@@ -151,12 +149,11 @@ id=tagged
interface-name=eth0.902
type=vlan
autoconnect=true
[ethernet]
[ipv4]
address=<nil>
method=manual
address=<nil>
route1=192.168.1.0/24,192.168.2.254
[vlan]
interface-name=eth0.902
parent=eth0
@@ -176,10 +173,10 @@ id=untagged
interface-name=eth0
type=ethernet
autoconnect=true
[ethernet]
[ipv4]
address=<nil>
method=manual
address=<nil>
[ipv6]
addr-gen-mode=stable-privacy

View File

@@ -1,5 +1,4 @@
{{- $filename := print "warewulf-unmanaged.conf" }}
{{- file $filename }}
{{ file "warewulf-unmanaged.conf" }}
# This file is autogenerated by warewulf
[main]

View File

@@ -1,60 +1,53 @@
{{- range $connection_id, $netdev := .NetDevs }}
{{- $filename := print "warewulf-" $connection_id ".conf" }}
{{- file $filename }}
{{- range $devname, $netdev := .NetDevs }}
{{ file (print "warewulf-" $devname ".conf") }}
# This file is autogenerated by warewulf
[connection]
id={{ $connection_id }}
id={{ $devname }}
interface-name={{ $netdev.Device }}
{{- if eq $netdev.Type "bond-slave" }}
type={{ default "ethernet" (lower $netdev.Type) }}
{{- if $netdev.Tags.master }}
master={{ $netdev.Tags.master }}
slave-type=bond
{{- $conn := split "_" $connection_id }}
{{- $master := $conn._0 }}
master={{ $master }}
type=ethernet
{{- else }}
type={{if $netdev.Type}}{{ $netdev.Type }}{{ else }}ethernet{{end}}
{{- end }}
{{- if $netdev.OnBoot }}
autoconnect=true
{{- end }}
{{- end }}
{{- if $netdev.Hwaddr }}
{{- if or (eq $netdev.Type "ethernet") (not $netdev.Type ) }}
[ethernet]
mac-address={{ $netdev.Hwaddr }}
{{- if $netdev.MTU }}
mtu={{ $netdev.MTU }}
{{- end }}
{{- end }}
{{- end }}
{{- if eq $netdev.Type "bond" }}
{{- if eq (lower $netdev.Type) "bond" }}
[bond]
downdelay=0
miimon=100
mode=802.3ad
xmit_hash_policy=layer2+3
updelay=0
downdelay={{ default 0 $netdev.Tags.downdelay }}
miimon={{ default 100 $netdev.Tags.miimon }}
mode={{ default "balance-rr" $netdev.Tags.mode }}
xmit_hash_policy={{ default "layer2+3" $netdev.Tags.xmit_hash_policy }}
updelay={{ default 0 $netdev.Tags.updelay }}
{{- end }}
{{- if eq $netdev.Type "infiniband" }}
{{- if eq (lower $netdev.Type) "infiniband" }}
[infiniband]
transport-mode=datagram
{{- if $netdev.MTU }}
mtu={{ $netdev.MTU }}
{{- end }}
{{- else }}
[ethernet]
{{- if $netdev.Hwaddr }}
mac-address={{ $netdev.Hwaddr }}
{{- end }}
{{- if $netdev.MTU }}
mtu={{ $netdev.MTU }}
{{- end }}
{{- end }}
{{- if ne $netdev.Type "bond-slave" }}
{{- if not $netdev.Tags.master }}
[ipv4]
{{- if not (eq $netdev.IpCIDR nil) }}
method=manual
{{- if $netdev.IpCIDR }}
address={{ $netdev.IpCIDR }}
{{- end }}
{{- if $netdev.Gateway }}
gateway={{ $netdev.Gateway }}
{{- end }}
method=manual
{{- $dns := "" }}
{{- range $tk, $tv := $netdev.Tags }}
{{- if eq (substr 0 3 $tk) "DNS" }}
@@ -63,12 +56,12 @@ method=manual
{{$tk}}={{$tv}}
{{- end }}
{{- end }}
{{- if ne $dns "" }}
{{- if $dns }}
dns={{$dns}}
{{- end }}
{{- end }}
{{- if eq $netdev.Type "vlan" }}
{{- if eq $netdev.Type "vlan" }}
[vlan]
interface-name={{ $netdev.Device }}
parent={{ $netdev.Tags.parent_device }}
@@ -79,7 +72,7 @@ id={{ $netdev.Tags.vlan_id }}
addr-gen-mode=stable-privacy
method=ignore
never-default=true
{{ if $netdev.Ipaddr6 -}}
{{- if $netdev.Ipaddr6 }}
ipaddr="{{ $netdev.Ipaddr6 }}"
{{- end }}
{{- end -}}
{{- end }}