Merge branch 'devel' of https://github.com/skvidal/ansible into devel

This commit is contained in:
Michael DeHaan 2012-08-16 21:21:37 -04:00
commit 1738440b13

View file

@ -57,6 +57,8 @@ def main(args):
help="set additional key=value variables from the CLI")
parser.add_option('-t', '--tags', dest='tags', default='all',
help="only run plays and tasks tagged with these values")
parser.add_option('--list-hosts', dest='listhosts', action='store_true',
help="dump out a list of hosts, each play will run against, does not run playbook!")
options, args = parser.parse_args(args)
@ -66,6 +68,7 @@ def main(args):
sshpass = None
sudopass = None
if not options.listhosts:
if options.ask_pass:
sshpass = getpass.getpass(prompt="SSH password: ")
if options.ask_sudo_pass:
@ -104,6 +107,21 @@ def main(args):
only_tags=only_tags,
subset=options.subset,
)
if options.listhosts:
playnum = 0
for play in pb.playbook:
playnum += 1
if 'hosts' in play:
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
try:
pb.run()