Exclude hosts header line in expand-groups
Ansible --list-hosts output looks like this: root@puppetmaster:~# ansible logstash-worker --list-hosts hosts (20): loggstash-worker01.openstack.org Which means we need to strip out the hosts (20): line. Change-Id: Id2ab90baadcf13836f9d605bab1cf13ebf3c1a70
This commit is contained in:
parent
7699226007
commit
9367e61fd9
@ -25,7 +25,7 @@ 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 >> $outfile
|
||||
ansible "~${pattern}" --list-hosts | grep -v '^ +hosts \([0-9]+\):' >> $outfile
|
||||
done
|
||||
|
||||
cp $outfile /etc/ansible/hosts/generated-groups
|
||||
|
Loading…
x
Reference in New Issue
Block a user