mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Merge pull request #7649 from sivel/vault-password-script
Allow --vault-password-file to work with a script as well as a flat file
This commit is contained in:
13
bin/ansible
13
bin/ansible
@@ -124,17 +124,8 @@ class Cli(object):
|
||||
(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)
|
||||
|
||||
# read vault_pass from a file
|
||||
if options.vault_password_file:
|
||||
this_path = os.path.expanduser(options.vault_password_file)
|
||||
try:
|
||||
f = open(this_path, "rb")
|
||||
tmp_vault_pass=f.read().strip()
|
||||
f.close()
|
||||
except (OSError, IOError), e:
|
||||
raise errors.AnsibleError("Could not read %s: %s" % (this_path, e))
|
||||
|
||||
if not options.ask_vault_pass:
|
||||
vault_pass = tmp_vault_pass
|
||||
if not options.ask_vault_pass and options.vault_password_file:
|
||||
vault_pass = utils.read_vault_file(options.vault_password_file)
|
||||
|
||||
inventory_manager = inventory.Inventory(options.inventory, vault_password=vault_pass)
|
||||
if options.subset:
|
||||
|
||||
@@ -120,17 +120,9 @@ def main(args):
|
||||
options.sudo_user = options.sudo_user or C.DEFAULT_SUDO_USER
|
||||
options.su_user = options.su_user or C.DEFAULT_SU_USER
|
||||
|
||||
if options.vault_password_file:
|
||||
this_path = os.path.expanduser(options.vault_password_file)
|
||||
try:
|
||||
f = open(this_path, "rb")
|
||||
tmp_vault_pass=f.read().strip()
|
||||
f.close()
|
||||
except (OSError, IOError), e:
|
||||
raise errors.AnsibleError("Could not read %s: %s" % (this_path, e))
|
||||
|
||||
if not options.ask_vault_pass:
|
||||
vault_pass = tmp_vault_pass
|
||||
# read vault_pass from a file
|
||||
if not options.ask_vault_pass and options.vault_password_file:
|
||||
vault_pass = utils.read_vault_file(options.vault_password_file)
|
||||
|
||||
extra_vars = {}
|
||||
for extra_vars_opt in options.extra_vars:
|
||||
|
||||
Reference in New Issue
Block a user