diff options
Diffstat (limited to 'roles')
-rw-r--r-- | roles/common/tasks/hosts.yml | 30 | ||||
-rw-r--r-- | roles/common/templates/etc/hostname.j2 | 1 | ||||
-rw-r--r-- | roles/common/templates/etc/mailname.j2 | 1 |
3 files changed, 16 insertions, 16 deletions
diff --git a/roles/common/tasks/hosts.yml b/roles/common/tasks/hosts.yml index f818635..b8e5931 100644 --- a/roles/common/tasks/hosts.yml +++ b/roles/common/tasks/hosts.yml @@ -1,29 +1,31 @@ - name: Set hostname - template: src=etc/hostname.j2 - dest=/etc/hostname - owner=root group=root - mode=0644 + # Use double quoted scalars to force expansion of escape sequences + # cf. https://groups.google.com/forum/#!topic/ansible-project/ZaB6o-eqDzw + copy: "content='{{ inventory_hostname_short }}\n' + dest=/etc/hostname + owner=root group=root + mode=0644" tags: hostname notify: - Refresh hostname - name: Set mailname - template: src=etc/mailname.j2 - dest=/etc/mailname - owner=root group=root - mode=0644 + copy: "content='{{ inventory_hostname }}\n' + dest=/etc/mailname + owner=root group=root + mode=0644" tags: mailname - name: Fix /etc/hosts (1) - lineinfile: dest=/etc/hosts create=yes - regexp="^127\.0\.0\.1\s+" - line="127.0.0.1 localhost" + lineinfile: "dest=/etc/hosts create=yes + regexp='^127\\.0\\.0\\.1\\s+' + line='127.0.0.1\tlocalhost'" tags: hosts - name: Fix /etc/hosts (2) - lineinfile: dest=/etc/hosts create=yes - regexp="^127\.0\.1\.1\s+" - line="127.0.1.1 {{ inventory_hostname }} {{ inventory_hostname_short }}" + lineinfile: "dest=/etc/hosts create=yes + regexp='^127\\.0\\.1\\.1\\s+' + line='127.0.1.1\t{{ inventory_hostname }} {{ inventory_hostname_short }}'" tags: hosts - meta: flush_handlers diff --git a/roles/common/templates/etc/hostname.j2 b/roles/common/templates/etc/hostname.j2 deleted file mode 100644 index 68fd234..0000000 --- a/roles/common/templates/etc/hostname.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ inventory_hostname_short }} diff --git a/roles/common/templates/etc/mailname.j2 b/roles/common/templates/etc/mailname.j2 deleted file mode 100644 index 1fad51f..0000000 --- a/roles/common/templates/etc/mailname.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ inventory_hostname }} |