mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 23:14:02 -07: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:
commit
4fc8d4b6fe
5 changed files with 40 additions and 25 deletions
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue