diff --git a/rho/vault.py b/rho/vault.py index 62eb611..72bda6b 100644 --- a/rho/vault.py +++ b/rho/vault.py @@ -12,6 +12,7 @@ from __future__ import print_function import os +import sys import json import uuid from tempfile import gettempdir @@ -19,6 +20,8 @@ from getpass import getpass import yaml from ansible.parsing.vault import VaultLib +from ansible.errors import AnsibleError +from rho.translation import _ as t def represent_none(self, _): @@ -88,7 +91,11 @@ def load(self, stream): :param stream: The stream to read data from :returns: The decrypted data """ - return self.vault.decrypt(stream) + try: + return self.vault.decrypt(stream) + except AnsibleError: + print(t("Unable to decrypt file using given vault password")) + sys.exit(1) def load_secure_file(self, secure_file): """ Read vault secured file and return python object