mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make --list-hosts consider all plays (in multiple playbooks)
Currently when more than one playbook is provided on the commandline, ansible-playbook --list-hosts will only consider the first playbook and stop. This change will make it work for the various different playbooks.
This commit is contained in:
parent
0ab3bd0034
commit
9ea26c75f9
1 changed files with 6 additions and 5 deletions
|
@ -119,6 +119,7 @@ def main(args):
|
||||||
)
|
)
|
||||||
|
|
||||||
if options.listhosts:
|
if options.listhosts:
|
||||||
|
print 'playbook: %s' % playbook
|
||||||
playnum = 0
|
playnum = 0
|
||||||
for play in pb.playbook:
|
for play in pb.playbook:
|
||||||
playnum += 1
|
playnum += 1
|
||||||
|
@ -126,11 +127,11 @@ def main(args):
|
||||||
label = 'unnamed'
|
label = 'unnamed'
|
||||||
if 'name' in play:
|
if 'name' in play:
|
||||||
label = play['name']
|
label = play['name']
|
||||||
print 'hosts in play %s: %s' % (playnum, label)
|
hosts = pb.inventory.list_hosts(play['hosts'])
|
||||||
for host in pb.inventory.list_hosts(play['hosts']):
|
print ' hosts in play %s (%s): #%d' % (playnum, label, len(hosts))
|
||||||
|
for host in hosts:
|
||||||
print ' %s' % host
|
print ' %s' % host
|
||||||
print '\n'
|
continue
|
||||||
return 0
|
|
||||||
|
|
||||||
if options.syntax:
|
if options.syntax:
|
||||||
# if we've not exited by now then we are fine.
|
# if we've not exited by now then we are fine.
|
||||||
|
|
Loading…
Reference in a new issue