Browse Source

Support ipv6 default address in /etc/hosts

Emmanuel Bouthenot 11 years ago
parent
commit
58dfec902a
1 changed files with 5 additions and 0 deletions
  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