Merge pull request #1741 from christopher-snapp/list-hosts

add list-hosts support to bin/ansible
This commit is contained in:
Michael DeHaan 2012-12-12 14:52:06 -08:00
commit aff6ae47ed

View file

@ -52,6 +52,8 @@ class Cli(object):
parser.add_option('-m', '--module-name', dest='module_name',
help="module name to execute (default=%s)" % C.DEFAULT_MODULE_NAME,
default=C.DEFAULT_MODULE_NAME)
parser.add_option('--list-hosts', dest='listhosts', action='store_true',
help="dump out a list of hosts matching input pattern, does not execute any modules!")
options, args = parser.parse_args()
self.callbacks.options = options
@ -73,6 +75,15 @@ class Cli(object):
print >>sys.stderr, "No hosts matched"
sys.exit(1)
if options.listhosts:
for host in hosts:
print ' %s' % host
sys.exit(0)
if options.module_name == 'command' and not options.module_args:
print >>sys.stderr, "No argument passed to command module"
sys.exit(1)
sshpass = None
sudopass = None
options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS