catch GPG error

This commit is contained in:
2024-02-29 09:54:38 +01:00
parent b524b2f15d
commit 1a27b50fb2

View File

@@ -11,7 +11,6 @@ import json
import os
import subprocess
import sys
import getpass
parser = argparse.ArgumentParser(description=__doc__)
subparsers = parser.add_subparsers(title="commands", dest="command", required=True)
@@ -160,9 +159,12 @@ def decrypt_string(host, var) -> str:
"ANSIBLE_LOAD_CALLBACK_PLUGINS": "1",
"ANSIBLE_STDOUT_CALLBACK": "json",
}
result = subprocess.run(
ansible_command, env=ansible_env, capture_output=True, text=True, check=False
)
try:
result = subprocess.run(
ansible_command, env=ansible_env, capture_output=True, text=True, check=True
)
except subprocess.CalledProcessError as e:
sys.exit(f"Decrypting the variable failed: {e.stderr}")
# Parse JSON
try: