handle unfound host
This commit is contained in:
@@ -86,7 +86,11 @@ def decrypt_string(host, var):
|
|||||||
result = subprocess.run(ansible_command, env=ansible_env, capture_output=True, text=True)
|
result = subprocess.run(ansible_command, env=ansible_env, capture_output=True, text=True)
|
||||||
|
|
||||||
# Parse JSON
|
# Parse JSON
|
||||||
|
try:
|
||||||
ansible_output = json.loads(result.stdout)["plays"][0]["tasks"][0]["hosts"]
|
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
|
# Attempt to create a :-separated list of host/values
|
||||||
output = {}
|
output = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user