Skip to content

Commit

Permalink
Before decrypting check if vault password is set or error early
Browse files Browse the repository at this point in the history
  • Loading branch information
jimi-c committed Sep 19, 2014
1 parent 5850467 commit 9d45f3a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ansible/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9d45f3a

Please sign in to comment.