From 23c6f4e7bf5e1d2636fe0bcf20ccc2df06242fe5 Mon Sep 17 00:00:00 2001 From: Max Mehl Date: Wed, 6 Dec 2023 13:43:15 +0100 Subject: [PATCH] using debug var instead of msg --- ansible-vault-tools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ansible-vault-tools.py b/ansible-vault-tools.py index cfbe33e..274355f 100755 --- a/ansible-vault-tools.py +++ b/ansible-vault-tools.py @@ -77,7 +77,7 @@ parser_allvars.add_argument( def convert_ansible_errors(error: str) -> str: """Convert typical Ansible errors to more user-friendly messages""" - if "The task includes an option with an undefined variable" in error: + if "VARIABLE IS NOT DEFINED" in error: return "(undefined variable)" # If no conversion was possible, return the original error @@ -204,7 +204,7 @@ def decrypt_string(host, var) -> str: """Decrypt/print a variable from one or multiple hosts""" # Run ansible msg for variable # Send return as JSON - ansible_command = ["ansible", host, "-m", "debug", "-a", f"msg={{{{ {var} }}}}"] + ansible_command = ["ansible", host, "-m", "debug", "-a", f"var={var}"] ansible_env = { "ANSIBLE_LOAD_CALLBACK_PLUGINS": "1", "ANSIBLE_STDOUT_CALLBACK": "json", @@ -222,7 +222,7 @@ def decrypt_string(host, var) -> str: # Attempt to create a :-separated list of host/values output = {} for hostname, values in ansible_output.items(): - output[hostname] = convert_ansible_errors(values["msg"]) + output[hostname] = convert_ansible_errors(values[var]) return format_data(output)