Merge "Avoid generated-groups when creating generated-groups"
This commit is contained in:
commit
929053f4a3
@ -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 $(</etc/ansible/groups.txt); do
|
||||
name=$(echo $line | cut -f1 -d' ')
|
||||
pattern=$(echo $line | cut -f2 -d' ')
|
||||
echo "[${name}]" >> $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
|
||||
|
Loading…
x
Reference in New Issue
Block a user