[PATCH 03/26] lucid: show exception tracebacks on task failures

Daniel Gomez <[email protected]> Tue, 19 May 2026 15:28:00 +0200
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
From: Daniel Gomez <[email protected]>

When an Ansible module raises an unhandled exception the full Python
traceback is attached to the result under the exception key. Lucid
already wrote that key to the log file but never surfaced it on screen,
so users watching a failing playbook saw only the high-level msg and
had to tail the log to find the real stack trace.

Append the exception text to the on-screen output in _display_output
whenever it is present, right after the msg block. The traceback now
appears inline at failure time, putting the root cause in front of the
user immediately while still preserving the existing log-file record.

Generated-by: Claude AI
Signed-off-by: Daniel Gomez <[email protected]>
---
 callback_plugins/lucid.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/callback_plugins/lucid.py b/callback_plugins/lucid.py
index 99848b57..0aa28eba 100644
--- a/callback_plugins/lucid.py
+++ b/callback_plugins/lucid.py
@@ -630,6 +630,10 @@ class CallbackModule(CallbackBase):
                 msg_text = json.dumps(msg_text, indent=2)
             output.append(f"\nMSG:\n{msg_text}")
 
+        # exception (Python traceback from module failures)
+        if "exception" in res and res["exception"]:
+            output.append(f"\nEXCEPTION:\n{res['exception']}")
+
         if output:
             self._display.display("".join(output))
 

-- 
2.53.0