diff --git a/bin/ansible b/bin/ansible index 38b74b3670..394d8a7942 100755 --- a/bin/ansible +++ b/bin/ansible @@ -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