diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2024-01-04 12:59:39 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2024-01-04 13:42:18 +0100 |
commit | 6691410f945719e62601c3d69d9b2ff9c4cfb4fb (patch) | |
tree | 9ea4170a6d5d50ac14a326f42fa8b13303734241 /tasks/hosts.yml | |
parent | 609574f51c5c08af71419bddc1be16ad5668882a (diff) |
Base system.
Diffstat (limited to 'tasks/hosts.yml')
-rw-r--r-- | tasks/hosts.yml | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tasks/hosts.yml b/tasks/hosts.yml new file mode 100644 index 0000000..b8e5931 --- /dev/null +++ b/tasks/hosts.yml @@ -0,0 +1,31 @@ +- name: Set hostname + # 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 + 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\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\t{{ inventory_hostname }} {{ inventory_hostname_short }}'" + tags: hosts + +- meta: flush_handlers |