Merge pull request #1629 from dagwieers/list-hosts-plays

Make --list-hosts consider all plays (in multiple playbooks)
pull/1648/head
Michael DeHaan 12 years ago
commit 20c65bf854

@ -124,6 +124,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
@ -131,11 +132,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))
print ' %s' % host for host in hosts:
print '\n' print ' %s' % host
return 0 continue
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…
Cancel
Save