From 9ba053c8851be740b4a5ac936a4d39499e132854 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Wed, 19 Feb 2014 11:23:46 -0500 Subject: [PATCH] Fix ansible cli to use vault for group var files --- bin/ansible | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/bin/ansible b/bin/ansible index a0464c142af..ada219f9ddb 100755 --- a/bin/ansible +++ b/bin/ansible @@ -84,6 +84,7 @@ class Cli(object): pattern = args[0] + """ inventory_manager = inventory.Inventory(options.inventory) if options.subset: inventory_manager.subset(options.subset) @@ -101,6 +102,7 @@ class Cli(object): and not options.module_args): callbacks.display("No argument passed to %s module" % options.module_name, color='red', stderr=True) sys.exit(1) + """ sshpass = None sudopass = None @@ -111,7 +113,27 @@ class Cli(object): options.ask_pass = False 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 - (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: options.su = True elif options.sudo_user or options.ask_sudo_pass: @@ -121,7 +143,6 @@ class Cli(object): if options.tree: utils.prepare_writeable_dir(options.tree) - runner = Runner( module_name=options.module_name, module_path=options.module_path, @@ -143,7 +164,8 @@ class Cli(object): diff=options.check, su=options.su, su_pass=su_pass, - su_user=options.su_user + su_user=options.su_user, + vault_pass=vault_pass ) if options.seconds: