|
@ -2,8 +2,8 @@ |
|
|
- name: populate inventory into hosts file |
|
|
- name: populate inventory into hosts file |
|
|
lineinfile: |
|
|
lineinfile: |
|
|
dest: /etc/hosts |
|
|
dest: /etc/hosts |
|
|
regexp: "^{{ hostvars[item].ansible_default_ipv4.address }} {{ item }}$" |
|
|
|
|
|
line: "{{ hostvars[item].ansible_default_ipv4.address }} {{ item }}" |
|
|
|
|
|
|
|
|
regexp: "^{{ hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address) }} {{ item }}$" |
|
|
|
|
|
line: "{{ hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address) }} {{ item }}" |
|
|
state: present |
|
|
state: present |
|
|
backup: yes |
|
|
backup: yes |
|
|
when: hostvars[item].ansible_default_ipv4.address is defined |
|
|
when: hostvars[item].ansible_default_ipv4.address is defined |
|
|