ansible-role-generate-tls-c.../tasks/populate-etc-hosts.yaml
Blallo 0bcb4b89b6
Optional tld
When updating /etc/hosts to add the hosts in the inventory, also add the name
postfixed with a configurable tld.
2021-01-24 18:37:15 +01:00

11 lines
349 B
YAML

---
- name: Add IP address of all hosts to all hosts
become: yes
lineinfile:
dest: /etc/hosts
regexp: '.*{{ item }}$'
line: "{{ hostvars[item].ansible_host }} {{item}}{% if gen_tls_tld is defined %} {{ item }}.{{ gen_tls_tld }}{% endif %}"
state: present
when: hostvars[item].ansible_host is defined
loop: "{{ groups.all }}"