Parcourir la source

Support ipv6 default address in /etc/hosts

Emmanuel Bouthenot il y a 11 ans
Parent
commit
58dfec902a
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      roles/common/templates/hosts.j2

+ 5 - 0
roles/common/templates/hosts.j2

@@ -4,7 +4,12 @@
 {% endif -%}
 
 127.0.0.1       localhost
+{% if ansible_default_ipv4 is defined %}
 {{ ansible_default_ipv4.address }}  {{ ansible_fqdn }}  {{ ansible_hostname }}
+{% endif %}
+{% if ansible_default_ipv6 is defined %}
+{{ ansible_default_ipv6.address }}  {{ ansible_fqdn }}  {{ ansible_hostname }}
+{% endif %}
 
 # The following lines are desirable for IPv6 capable hosts
 ::1             localhost       ip6-localhost   ip6-loopback