Forráskód Böngészése

Create /etc/hosts from template

Markus Lindenberg 9 éve
szülő
commit
b99963ac7c

+ 2 - 2
roles/common-net/tasks/hostname.yml

@@ -3,5 +3,5 @@
 - name: Ensure hostname is set
   hostname: name={{ inventory_hostname_short }}
 
-- name: Ensure /etc/hosts entry for hostname exists
-  lineinfile: dest=/etc/hosts regexp="^127\\.0\\.1\\.1" line="127.0.1.1 {{ inventory_hostname }} {{ inventory_hostname_short }}"
+- name: ensure hostname is configured in /etc/hosts
+  template: src=hosts.j2 dest=/etc/hosts

+ 7 - 0
roles/common-net/templates/hosts.j2

@@ -0,0 +1,7 @@
+127.0.0.1   localhost
+127.0.1.1   {{ inventory_hostname }} {{ inventory_hostname_short }}
+
+# The following lines are desirable for IPv6 capable hosts
+::1     localhost ip6-localhost ip6-loopback
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters