mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-08 19:53:12 +00:00
Merge pull request #1629 from dagwieers/list-hosts-plays
Make --list-hosts consider all plays (in multiple playbooks)
This commit is contained in:
@@ -124,6 +124,7 @@ def main(args):
|
||||
)
|
||||
|
||||
if options.listhosts:
|
||||
print 'playbook: %s' % playbook
|
||||
playnum = 0
|
||||
for play in pb.playbook:
|
||||
playnum += 1
|
||||
@@ -131,11 +132,11 @@ def main(args):
|
||||
label = 'unnamed'
|
||||
if 'name' in play:
|
||||
label = play['name']
|
||||
print 'hosts in play %s: %s' % (playnum, label)
|
||||
for host in pb.inventory.list_hosts(play['hosts']):
|
||||
print ' %s' % host
|
||||
print '\n'
|
||||
return 0
|
||||
hosts = pb.inventory.list_hosts(play['hosts'])
|
||||
print ' hosts in play %s (%s): #%d' % (playnum, label, len(hosts))
|
||||
for host in hosts:
|
||||
print ' %s' % host
|
||||
continue
|
||||
|
||||
if options.syntax:
|
||||
# if we've not exited by now then we are fine.
|
||||
|
||||
Reference in New Issue
Block a user