# callbacks with --check

**URL:** <https://forum.ansible.com/t/callbacks-with-check/20280>\
**Category:** Ansible Project\
**Created:** [January 19, 2016, 6:03pm UTC](https://forum.ansible.com/t/callbacks-with-check/20280 "2016-01-19T18:03:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Biancaniello](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_Biancaniello](https://forum.ansible.com/u/Mike_Biancaniello)\
**Post date:** [January 19, 2016, 6:03pm UTC](https://forum.ansible.com/t/callbacks-with-check/20280/1 "2016-01-19T18:03:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 19, 2016, 7:10pm UTC](https://forum.ansible.com/t/callbacks-with-check/20280/2 "2016-01-19T19:10:55Z")

</div>

There is an approach that Brian Coca and I have been working on which would be to do the following:

from **main** import cli

and then in **init** of your callback:

if cli.options.check:  
self.disabled = True

Eventually, the plan is to make `cli.options` available to all callbacks natively via `self._options`. See [https://github.com/ansible/ansible/pull/13412/files](https://github.com/ansible/ansible/pull/13412/files)

---

<div class="post-metadata">

**Author:** ![Mike\_Biancaniello](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_Biancaniello](https://forum.ansible.com/u/Mike_Biancaniello)\
**Post date:** [January 19, 2016, 9:55pm UTC](https://forum.ansible.com/t/callbacks-with-check/20280/3 "2016-01-19T21:55:23Z")

</div>

worked great, thanks!

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

`

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 19, 2016, 10:20pm UTC](https://forum.ansible.com/t/callbacks-with-check/20280/4 "2016-01-19T22:20:24Z")

</div>

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 😉
