handle unfound host

This commit is contained in:
2023-12-06 12:23:24 +01:00
parent a2e6a120ca
commit bd1d257634

View File

@@ -86,7 +86,11 @@ def decrypt_string(host, var):
result = subprocess.run(ansible_command, env=ansible_env, capture_output=True, text=True)
# Parse JSON
ansible_output = json.loads(result.stdout)["plays"][0]["tasks"][0]["hosts"]
try:
ansible_output = json.loads(result.stdout)["plays"][0]["tasks"][0]["hosts"]
except IndexError:
print(f"ERROR: Host '{host}' not found.")
return ""
# Attempt to create a :-separated list of host/values
output = {}