diff --git a/CHANGELOG.md b/CHANGELOG.md index fa17f4c5..4466a2fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Rename Netdev ip6addr to ipaddr6 for consistency - Set `addr-gen-mode=eui64` - Set dnsmasq to listen to the Warewulf interface to prevent to binding to localhost:53 +- Added Ipv6 support to `/etc/hosts` on host and nodes. ### Removed diff --git a/overlays/host/internal/host_test.go b/overlays/host/internal/host_test.go index 265bc0ce..92aa7ce3 100644 --- a/overlays/host/internal/host_test.go +++ b/overlays/host/internal/host_test.go @@ -333,6 +333,14 @@ Filename: etc/hosts 192.168.3.22 node1-secondary node1-wwnet1 # Entry for node2 192.168.3.23 node2 node2-default node2-wwnet0 + +# Warewulf Ipv6 +2001:db8::1 %HOSTNAME% warewulf +# Entry for node1 +2001:db8::111 node1 node1-default node1-wwnet0 +2001:db8::112 node1-secondary node1-wwnet1 +# Entry for node2 +2001:db8::121 node2 node2-default node2-wwnet0 ` const host_ssh_setup_csh = `backupFile: true diff --git a/overlays/host/rootfs/etc/hosts.ww b/overlays/host/rootfs/etc/hosts.ww index 5ffa92e7..b0b2d752 100644 --- a/overlays/host/rootfs/etc/hosts.ww +++ b/overlays/host/rootfs/etc/hosts.ww @@ -14,3 +14,20 @@ {{- end }}{{/* if ip */}} {{- end }}{{/* for each network device */}} {{- end }}{{/* for each node */}} + +{{- if .Ipv6 }} + +# Warewulf Ipv6 +{{$.Ipaddr6}} {{$.BuildHost}} warewulf + +{{- range $node := $.AllNodes}}{{/* for each node */}} +# Entry for {{$node.Id}} +{{- range $devname, $netdev := $node.NetDevs}}{{/* for each network device on the node */}} +{{- if $netdev.Ipaddr6}}{{/* if we have an ip address on this network device */}} +{{- /* emit the node name as hostname if this is the primary */}} +{{$netdev.Ipaddr6}} {{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 */}} + +{{- end }}{{/* for .IPv6 */}} diff --git a/overlays/hosts/rootfs/etc/hosts.ww b/overlays/hosts/rootfs/etc/hosts.ww index 415b1d98..bf7cc4c9 100644 --- a/overlays/hosts/rootfs/etc/hosts.ww +++ b/overlays/hosts/rootfs/etc/hosts.ww @@ -12,3 +12,20 @@ {{- end }} {{- end }} {{- end }} + +{{- if .Ipv6 }} + +# Warewulf Ipv6 +{{$.Ipaddr6}} {{$.BuildHost}} warewulf + +{{- range $node := $.AllNodes}}{{/* for each node */}} +# Entry for {{$node.Id}} +{{- range $devname, $netdev := $node.NetDevs}}{{/* for each network device on the node */}} +{{- if $netdev.Ipaddr6}}{{/* if we have an ip address on this network device */}} +{{- /* emit the node name as hostname if this is the primary */}} +{{$netdev.Ipaddr6}} {{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 */}} + +{{- end }}{{/* for .IPv6 */}}