From 61f29fb7ba380acb48316a9c60cdb0c23d74a9ca Mon Sep 17 00:00:00 2001 From: Menno van Leeuwen Date: Tue, 11 Mar 2025 20:22:17 +0100 Subject: [PATCH] feat: enhance 1Password lookup module to handle empty output and improve logging --- config/ansible/plugins/lookup/onepassword.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/ansible/plugins/lookup/onepassword.py b/config/ansible/plugins/lookup/onepassword.py index 8d9d2b2..7464082 100644 --- a/config/ansible/plugins/lookup/onepassword.py +++ b/config/ansible/plugins/lookup/onepassword.py @@ -70,7 +70,13 @@ class LookupModule(LookupBase): text=True, check=True ) - return [result.stdout.strip()] + output = result.stdout.strip() + display.vvv(f"1Password output for ref '{ref}': '{output}'") + + if not output: + display.warning(f"1Password returned empty output for ref '{ref}'") + + return [output] except subprocess.CalledProcessError as e: error_msg = e.stderr.strip() display.warning(f"Error executing 1Password CLI: {error_msg}")