Quellcode durchsuchen

Support ipv6 default address in /etc/hosts

Emmanuel Bouthenot vor 11 Jahren
Ursprung
Commit
58dfec902a
1 geänderte Dateien mit 5 neuen und 0 gelöschten Zeilen
  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