Fix ansible cli to use vault for group var files

pull/6058/head
James Tanner 11 years ago
parent 286ca505bd
commit 9ba053c885

@ -84,6 +84,7 @@ class Cli(object):
pattern = args[0] pattern = args[0]
"""
inventory_manager = inventory.Inventory(options.inventory) inventory_manager = inventory.Inventory(options.inventory)
if options.subset: if options.subset:
inventory_manager.subset(options.subset) inventory_manager.subset(options.subset)
@ -101,6 +102,7 @@ class Cli(object):
and not options.module_args): and not options.module_args):
callbacks.display("No argument passed to %s module" % options.module_name, color='red', stderr=True) callbacks.display("No argument passed to %s module" % options.module_name, color='red', stderr=True)
sys.exit(1) sys.exit(1)
"""
sshpass = None sshpass = None
sudopass = None sudopass = None
@ -111,7 +113,27 @@ class Cli(object):
options.ask_pass = False options.ask_pass = False
options.ask_sudo_pass = options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS options.ask_sudo_pass = options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS
options.ask_su_pass = options.ask_su_pass or C.DEFAULT_ASK_SU_PASS options.ask_su_pass = options.ask_su_pass or C.DEFAULT_ASK_SU_PASS
(sshpass, sudopass, su_pass) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass, ask_su_pass=options.ask_su_pass) (sshpass, sudopass, su_pass, vault_pass) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass, ask_su_pass=options.ask_su_pass, ask_vault_pass=options.ask_vault_pass)
inventory_manager = inventory.Inventory(options.inventory)
if options.subset:
inventory_manager.subset(options.subset)
hosts = inventory_manager.list_hosts(pattern)
if len(hosts) == 0:
callbacks.display("No hosts matched")
sys.exit(0)
if options.listhosts:
for host in hosts:
callbacks.display(' %s' % host)
sys.exit(0)
if ((options.module_name == 'command' or options.module_name == 'shell')
and not options.module_args):
callbacks.display("No argument passed to %s module" % options.module_name, color='red', stderr=True)
sys.exit(1)
if options.su_user or options.ask_su_pass: if options.su_user or options.ask_su_pass:
options.su = True options.su = True
elif options.sudo_user or options.ask_sudo_pass: elif options.sudo_user or options.ask_sudo_pass:
@ -121,7 +143,6 @@ class Cli(object):
if options.tree: if options.tree:
utils.prepare_writeable_dir(options.tree) utils.prepare_writeable_dir(options.tree)
runner = Runner( runner = Runner(
module_name=options.module_name, module_name=options.module_name,
module_path=options.module_path, module_path=options.module_path,
@ -143,7 +164,8 @@ class Cli(object):
diff=options.check, diff=options.check,
su=options.su, su=options.su,
su_pass=su_pass, su_pass=su_pass,
su_user=options.su_user su_user=options.su_user,
vault_pass=vault_pass
) )
if options.seconds: if options.seconds:

Loading…
Cancel
Save