Browse Source

Update /etc/hosts when hostname changes

Markus Lindenberg 9 years ago
parent
commit
0bc1bdfd45
1 changed files with 3 additions and 0 deletions
  1. 3 0
      roles/internal/ffdo.hostname/tasks/main.yml

+ 3 - 0
roles/internal/ffdo.hostname/tasks/main.yml

@@ -3,3 +3,6 @@
 
 - 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 }}"