浏览代码

Support ipv6 default address in /etc/hosts

Emmanuel Bouthenot 11 年之前
父节点
当前提交
58dfec902a
共有 1 个文件被更改,包括 5 次插入0 次删除
  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