Skip to content

Commit

Permalink
Fix Alpine and Mariner /etc/hosts templates
Browse files Browse the repository at this point in the history
Revert the changes I introduced with #1084, these had the side-effect
of causing "hostname" problems. Fixes #4771.

Also remove the "::1 {{fqdn}} {{hostname}}" entry as this this being
results in strange behaviour with both Busybox "hostname -i" (returns
"127.0.0.1", or "127.0.0.1 A.B.C.D" if an additional non-loopback IP
entry in /etc/hosts) and Coreutils "hostname -i" (returns "::1" in
both situations), commands whereas if the "::1" entry is removed then
both Busybox and Coreutils behave the the same fashion returning
"127.0.0.1" or "127.0.0.1 A.B.C.D" as appropriate.

Also correct hosts.mariner.tmpli file it was not valid (every line
was prefixed with "+").
  • Loading branch information
dermotbradley committed Jan 16, 2024
1 parent 034a5cd commit 34e8cd2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
9 changes: 4 additions & 5 deletions templates/hosts.alpine.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ you need to add the following to config:
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
# The following lines are desirable for IPv4 capable hosts
127.0.1.1 {{hostname}} {{fqdn}}
127.0.0.1 localhost localhost.localdomain
127.0.0.1 localhost4 localhost4.localdomain4
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4
127.0.1.1 {{fqdn}} {{hostname}}

# The following lines are desirable for IPv6 capable hosts
::1 {{hostname}} {{fqdn}}
::1 localhost6 localhost6.localdomain6
::1 localhost6.localdomain6 localhost6

ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
44 changes: 22 additions & 22 deletions templates/hosts.mariner.tmpl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
+## template:jinja
+{#
+This file /etc/cloud/templates/hosts.mariner.tmpl is only utilized
+if enabled in cloud-config. Specifically, in order to enable it
+you need to add the following to config:
+ manage_etc_hosts: True
+-#}
+# Your system has configured 'manage_etc_hosts' as True.
+# As a result, if you wish for changes to this file to persist
+# then you will need to either
+# a.) make changes to the master file in /etc/cloud/templates/hosts.mariner.tmpl
+# b.) change or remove the value of 'manage_etc_hosts' in
+# /etc/cloud/cloud.cfg or cloud-config from user-data
+#
+# The following lines are desirable for IPv4 capable hosts
+127.0.0.1 {{fqdn}} {{hostname}}
+127.0.0.1 localhost.localdomain localhost
+127.0.0.1 localhost4.localdomain4 localhost4
+
+# The following lines are desirable for IPv6 capable hosts
+::1 {{fqdn}} {{hostname}}
+::1 localhost6.localdomain6 localhost6
## template:jinja
{#
This file /etc/cloud/templates/hosts.mariner.tmpl is only utilized
if enabled in cloud-config. Specifically, in order to enable it
you need to add the following to config:
manage_etc_hosts: True
-#}
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.mariner.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 {{fqdn}} {{hostname}}
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

# The following lines are desirable for IPv6 capable hosts
::1 {{fqdn}} {{hostname}}
::1 localhost6.localdomain6 localhost6

0 comments on commit 34e8cd2

Please sign in to comment.