summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2014-09-19 22:08:38 +0200
committerJames Cammarata <jimi@sngx.net>2014-09-19 22:10:30 +0200
commit9d45f3a65e7d94e9d25ee861d5c1a68257b69952 (patch)
tree7a2027e7f954b38c35afbf9c472801c1b7445323 /lib
parentMerge pull request #9060 from jamespharaoh/apt-lang (diff)
downloadansible-9d45f3a65e7d94e9d25ee861d5c1a68257b69952.tar.xz
ansible-9d45f3a65e7d94e9d25ee861d5c1a68257b69952.zip
Before decrypting check if vault password is set or error early
Fixes #8926
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/utils/__init__.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py
index 6da1f9a030..647a61d696 100644
--- a/lib/ansible/utils/__init__.py
+++ b/lib/ansible/utils/__init__.py
@@ -738,6 +738,11 @@ def parse_yaml_from_file(path, vault_password=None):
vault = VaultLib(password=vault_password)
if vault.is_encrypted(data):
+ # if the file is encrypted and no password was specified,
+ # the decrypt call would throw an error, but we check first
+ # since the decrypt function doesn't know the file name
+ if vault_password is None:
+ raise errors.AnsibleError("A vault password must be specified to decrypt %s" % path)
data = vault.decrypt(data)
show_content = False