Skip to content
Snippets Groups Projects
Commit 9156d1ec authored by Antoine Legrand's avatar Antoine Legrand
Browse files

Merge pull request #76 from rackn/dns-ip

Use IP is specified, otherwise use the ansible discovered address.
parents babf42f0 fe5ec398
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,8 @@
- name: populate inventory into hosts file
lineinfile:
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
backup: yes
when: hostvars[item].ansible_default_ipv4.address is defined
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment