Files
warewulf/etc/hosts.tmpl
MatthewHink f8f689bc99 Fix network name in /etc/hosts. Fixes #247.
For hosts with ip addresses, the hosts file entry should be:
<ip> <node_name>-<net-name> <node_name>-<network_device>

For the default network interface, the node name is included as well:
<ip> <node_name> <node_name>-<net-name> <node_name>-<network_device>
2022-01-28 10:09:47 -05:00

16 lines
872 B
Cheetah

{{$.PrevHostFile}}# Do not edit after this line - these host entries are maintained by 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 */}}
{{- if $netdev.Default.GetB}} {{/* emit the node name as hostname if this is the default */}}
{{$netdev.Ipaddr.Get}} {{$node.Id.Get}} {{$node.Id.Get}}-{{$devname}} {{$node.Id.Get}}-{{$netdev.Device.Get}}
{{- else}}
{{$netdev.Ipaddr.Get}} {{$node.Id.Get}}-{{$devname}} {{$node.Id.Get}}-{{$netdev.Device.Get}}
{{- end}} {{/* end if default */}}
{{- end}} {{/* end if ip */}}
{{- end}} {{/* end for each network device */}}
{{end}} {{/* end for each node */}}