From 35579d6d0a5f0fb2c1a4e1d4848ed647c5f0bd39 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Tue, 21 Feb 2023 01:39:49 -0700 Subject: [PATCH] Emit canonical hostnames first The hosts file man page (`man hosts`) states: > This file is a simple text file that associates IP addresses with > hostnames, one line per IP address. For each host a single line should > be present with the following information: > > IP_address canonical_hostname [aliases...] As such, it seems that the hostname should be first in the list. This is particularly true for the `warewulf` alias for the server itself, which is certainly an alias for the canonical hostname. Signed-off-by: Jonathon Anderson --- CHANGELOG.md | 5 +++++ overlays/generic/etc/hosts.ww | 12 +++++------- overlays/host/etc/hosts.ww | 12 +++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d70fe0..d9c14ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The correct header is now displayed when `-al` flags are specified to overlay list. +### Changed + +- The primary hostname and warewulf server fqdn are now the canonical name in + `/etc/hosts` + ## [4.4.0] 2023-01-18 ### Added diff --git a/overlays/generic/etc/hosts.ww b/overlays/generic/etc/hosts.ww index 6ab23cdc..3fe21b65 100644 --- a/overlays/generic/etc/hosts.ww +++ b/overlays/generic/etc/hosts.ww @@ -4,16 +4,14 @@ # Warewulf Server -{{$.Ipaddr}} warewulf {{$.BuildHost}} +{{$.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 */}} {{- /* 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}} -{{- end}} {{/* end if ip */}} -{{- end}} {{/* end for each network device */}} -{{- end}} {{/* end for each node */}} +{{$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}} +{{- end }}{{/* if ip */}} +{{- end }}{{/* for each network device */}} +{{- end }}{{/* for each node */}} diff --git a/overlays/host/etc/hosts.ww b/overlays/host/etc/hosts.ww index 3f5f9caf..92a93378 100644 --- a/overlays/host/etc/hosts.ww +++ b/overlays/host/etc/hosts.ww @@ -6,16 +6,14 @@ # Warewulf Server -{{$.Ipaddr}} warewulf {{$.BuildHost}} +{{$.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 */}} {{- /* 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}} -{{- end}} {{/* end if ip */}} -{{- end}} {{/* end for each network device */}} -{{- end}} {{/* end for each node */}} +{{$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}} +{{- end }}{{/* if ip */}} +{{- end }}{{/* for each network device */}} +{{- end }}{{/* for each node */}}