From fe5ec398bfd5bcea96b8b4aceba823acdcb68d8d Mon Sep 17 00:00:00 2001 From: Greg Althaus Date: Tue, 19 Jan 2016 16:54:29 -0600 Subject: [PATCH] Use IP is specified, otherwise use the ansible discovered address. This fixes cases for use in Vagrant environments. --- roles/dnsmasq/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/dnsmasq/tasks/main.yml b/roles/dnsmasq/tasks/main.yml index ccff170f9..a0bf29387 100644 --- a/roles/dnsmasq/tasks/main.yml +++ b/roles/dnsmasq/tasks/main.yml @@ -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