summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2014-07-14 10:57:16 -0500
committerJames Cammarata <jimi@sngx.net>2014-07-14 10:57:16 -0500
commit4fc8d4b6feaa9770bce17beecc4b2de969386f1b (patch)
tree86065c46046c5b29daaaa4608105526477ec1abe /bin
parente3abaa30b6343aca645f52f04b783cfa3d9dcd15 (diff)
parent19f5ce2c9c86d665466f4f82668de8e769d63aa1 (diff)
downloadansible-4fc8d4b6feaa9770bce17beecc4b2de969386f1b.tar.gz
Merge pull request #7649 from sivel/vault-password-script
Allow --vault-password-file to work with a script as well as a flat file
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ansible13
-rwxr-xr-xbin/ansible-playbook14
2 files changed, 5 insertions, 22 deletions
diff --git a/bin/ansible b/bin/ansible
index 7e767b2f7d..aa6941a7c2 100755
--- a/bin/ansible
+++ b/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:
diff --git a/bin/ansible-playbook b/bin/ansible-playbook
index 149a9f1c6e..3d05d8e29c 100755
--- a/bin/ansible-playbook
+++ b/bin/ansible-playbook
@@ -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: