I am trying to put together a logging module to log changes, but I do not want to log anything when run in check-mode (because no changes were made, so this would be confusing to anyone reading the logs).
Is there any way to do this? I can’t find any place where play_context (or anything else that might have that info) is passed to a callback_plugin.
Is there a way to do this in 1.94?
For now, I added to my callback:
`
from ansible import version as ANSIBLE_VERSION
if not ANSIBLE_VERSION.startswith(‘2’):
from ansible.callbacks import display
display(“Logging not supported in Ansible <2.0”,‘red’)
from ansible.callback_plugins.noop import CallbackModule
I think you can check self.playbook.check in a callback for 1.x. I’m not sure how soon you can access self.playbook. It may not be accessible until playbook_on_start. I’ll leave that for you to determine