Don't prompt for password info if the pattern wouldn't have matched any hosts. Also convert

Runner() usage to the new inventory model.
pull/191/head
Michael DeHaan 13 years ago
parent 3081bb93f1
commit a8d748220b

@ -29,6 +29,7 @@ import ansible.constants as C
from ansible import utils from ansible import utils
from ansible import errors from ansible import errors
from ansible import callbacks from ansible import callbacks
from ansible import inventory
######################################################## ########################################################
@ -69,6 +70,13 @@ class Cli(object):
''' use Runner lib to do SSH things ''' ''' use Runner lib to do SSH things '''
pattern = args[0] pattern = args[0]
inventory_manager = inventory.Inventory(options.inventory)
hosts = inventory_manager.list_hosts(pattern)
if len(hosts) == 0:
print >>sys.stderr, "No hosts matched"
sys.exit(1)
sshpass = None sshpass = None
sudopass = None sudopass = None
if options.ask_pass: if options.ask_pass:
@ -78,7 +86,6 @@ class Cli(object):
if options.tree: if options.tree:
utils.prepare_writeable_dir(options.tree) utils.prepare_writeable_dir(options.tree)
if options.seconds: if options.seconds:
print "background launch...\n\n" print "background launch...\n\n"
@ -86,7 +93,7 @@ class Cli(object):
module_name=options.module_name, module_path=options.module_path, module_name=options.module_name, module_path=options.module_path,
module_args=options.module_args, module_args=options.module_args,
remote_user=options.remote_user, remote_pass=sshpass, remote_user=options.remote_user, remote_pass=sshpass,
host_list=options.inventory, timeout=options.timeout, inventory=inventory_manager, timeout=options.timeout,
forks=options.forks, forks=options.forks,
background=options.seconds, pattern=pattern, background=options.seconds, pattern=pattern,
callbacks=self.callbacks, sudo=options.sudo, callbacks=self.callbacks, sudo=options.sudo,

Loading…
Cancel
Save