diff --git a/modules/openstack_project/files/puppetmaster/expand-groups.sh b/modules/openstack_project/files/puppetmaster/expand-groups.sh index 678ce0d45c..626568728f 100644 --- a/modules/openstack_project/files/puppetmaster/expand-groups.sh +++ b/modules/openstack_project/files/puppetmaster/expand-groups.sh @@ -24,12 +24,24 @@ echo "# This file is autogenerated" > $outfile unset OS_CLOUD unset OS_REGION_NAME +# Because we are generating "generated-groups", we need to work on an +# inventory without out it ... otherwise entries that have actually +# disappeared (according to /etc/ansible/hosts/openstack's live list) +# will keep coming back as "ansible --list" finds them in the +# generated-groups file. Later versions of ansible have a +# "inventory_ignore_patterns" that might help, we just copy & remove +# in a separate inventory +inv=${outdir}/hosts +mkdir ${inv} +cp /etc/ansible/hosts/* ${inv} +rm -f ${inv}/generated-groups* + IFS=$'\n' for line in $(> $outfile - ansible "${pattern}" --list-hosts | egrep -v '^ +hosts \([0-9]+\):' >> $outfile + ansible -i ${inv} "${pattern}" --list-hosts | egrep -v '^ +hosts \([0-9]+\):' >> $outfile done cp $outfile /etc/ansible/hosts/generated-groups