summaryrefslogtreecommitdiff
path: root/lib/ansible/utils/encrypt.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/utils/encrypt.py')
-rw-r--r--lib/ansible/utils/encrypt.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/ansible/utils/encrypt.py b/lib/ansible/utils/encrypt.py
index 4cb70b7098..cef78a663b 100644
--- a/lib/ansible/utils/encrypt.py
+++ b/lib/ansible/utils/encrypt.py
@@ -231,12 +231,15 @@ class PasslibHash(BaseHash):
settings['ident'] = ident
# starting with passlib 1.7 'using' and 'hash' should be used instead of 'encrypt'
- if hasattr(self.crypt_algo, 'hash'):
- result = self.crypt_algo.using(**settings).hash(secret)
- elif hasattr(self.crypt_algo, 'encrypt'):
- result = self.crypt_algo.encrypt(secret, **settings)
- else:
- raise AnsibleError("installed passlib version %s not supported" % passlib.__version__)
+ try:
+ if hasattr(self.crypt_algo, 'hash'):
+ result = self.crypt_algo.using(**settings).hash(secret)
+ elif hasattr(self.crypt_algo, 'encrypt'):
+ result = self.crypt_algo.encrypt(secret, **settings)
+ else:
+ raise AnsibleError("installed passlib version %s not supported" % passlib.__version__)
+ except ValueError as e:
+ raise AnsibleError("Could not hash the secret.", orig_exc=e)
# passlib.hash should always return something or raise an exception.
# Still ensure that there is always a result.