Debugging Ansible Modules
From time to time, you might want to debug an ansible module that you are developing. Simply adding ‘print’ statements doesn’t do the trick, but you can peform the following:
By default, these messages will appear in syslog or journalctl, prepended with ‘ansible’ for easy grep’ing.
Action Plugins don’t seem to be as easy.
Here’s a work around:
from __main__ import display
# pylint: disable=ungrouped-imports; this is the standard way how to import
# the default display object in Ansible action plugins.
from ansible.utils.display import Display
display = Display()
These will be printed to stdout.