mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix ansible cli to use vault for group var files
This commit is contained in:
parent
286ca505bd
commit
9ba053c885
1 changed files with 34 additions and 12 deletions
46
bin/ansible
46
bin/ansible
|
@ -84,6 +84,37 @@ class Cli(object):
|
||||||
|
|
||||||
pattern = args[0]
|
pattern = args[0]
|
||||||
|
|
||||||
|
"""
|
||||||
|
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)
|
||||||
|
"""
|
||||||
|
|
||||||
|
sshpass = None
|
||||||
|
sudopass = None
|
||||||
|
su_pass = None
|
||||||
|
options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS
|
||||||
|
# Never ask for an SSH password when we run with local connection
|
||||||
|
if options.connection == "local":
|
||||||
|
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, 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)
|
inventory_manager = inventory.Inventory(options.inventory)
|
||||||
if options.subset:
|
if options.subset:
|
||||||
inventory_manager.subset(options.subset)
|
inventory_manager.subset(options.subset)
|
||||||
|
@ -102,16 +133,7 @@ class Cli(object):
|
||||||
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
|
|
||||||
sudopass = None
|
|
||||||
su_pass = None
|
|
||||||
options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS
|
|
||||||
# Never ask for an SSH password when we run with local connection
|
|
||||||
if options.connection == "local":
|
|
||||||
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)
|
|
||||||
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…
Reference in a new issue