diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2013-12-15 04:49:50 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-06-07 02:51:23 +0200 |
commit | 3d2f023cb27126e879ac3522169cf813507b58ba (patch) | |
tree | beb466a21b341fde3975f3fa76bdd2967dcf8adc | |
parent | 827332364b00d3b47367fa97901dab8f4bfe4e91 (diff) |
Force expansion of escape sequences.
By using double quoted scalars, cf.
https://groups.google.com/forum/#!topic/ansible-project/ZaB6o-eqDzw
-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 }} |