I am aware about ansible -vvv
option but I don't want to see verbose output for all commands, I an interested in seeing details only if the task fails.
How can I achieve this?
PS. Please provide a solution that does scale, having to edit each task would not make any sense.
I think there is only one way: You could edit the default callback plugin (or write your own callback plugin) which you will find here (by default)
site-packages/ansible/plugins/callback/default.py
See line 40 in
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/callback/default.py
and just change the if
condition accordingly.
For Example replace lines 40-47 by:
msg = "An exception occurred during task execution. The full traceback is:\n" + result._result['exception']
self._display.display(msg, color=C.COLOR_ERROR)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With