diff --git a/roles/clusterlust.hosts/tasks/main.yml b/roles/clusterlust.hosts/tasks/main.yml new file mode 100644 index 0000000..0bc5ddc --- /dev/null +++ b/roles/clusterlust.hosts/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- name: Create /etc/hosts file + ansible.builtin.template: + src: hosts.j2 + dest: /etc/hosts + owner: root + group: root + mode: '0644' diff --git a/roles/clusterlust.hosts/templates/hosts.j2 b/roles/clusterlust.hosts/templates/hosts.j2 new file mode 100644 index 0000000..c8e1f15 --- /dev/null +++ b/roles/clusterlust.hosts/templates/hosts.j2 @@ -0,0 +1,6 @@ +# {{ ansible_managed }} +127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 +::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 +{% for host in groups['all'] %} +{{ hostvars[host]['ansible_host'] }} {{ host }} +{% endfor %}