From 79dec8da000cb8397c5e0b990229c6f3cbb20d75 Mon Sep 17 00:00:00 2001 From: Chris Hines <chris.hines@monash.edu> Date: Wed, 13 Jul 2016 04:31:53 +0000 Subject: [PATCH] update the process for generating the /etc/hosts file to make it more robust --- roles/calculateEtcHosts/files/makehosts.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/roles/calculateEtcHosts/files/makehosts.py b/roles/calculateEtcHosts/files/makehosts.py index b56e2817..724d0530 100755 --- a/roles/calculateEtcHosts/files/makehosts.py +++ b/roles/calculateEtcHosts/files/makehosts.py @@ -25,10 +25,12 @@ for group in d['groups'].keys(): for h in hosts.keys(): if d['hostvars'].has_key(h): - string="%s"%(d['hostvars'][h]['ansible_eth0']['ipv4']['address']) - for name in hosts[h]: - string=string+" %s"%(name) - print string + for addr in d['hostvars'][h]['ansible_all_ipv4_addresses']: + if "172.16.200" in addr: + string="%s"%addr + for name in hosts[h]: + string=string+" %s"%(name) + print string for h in hosts.keys(): if d['hostvars'].has_key(h): -- GitLab