# Feature idea: check\_mode for callbacks

**URL:** <https://forum.ansible.com/t/feature-idea-check-mode-for-callbacks/16524>\
**Category:** Ansible Developer\
**Created:** [October 16, 2014, 12:20am UTC](https://forum.ansible.com/t/feature-idea-check-mode-for-callbacks/16524 "2014-10-16T00:20:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesse\_Szwedko](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jesse\_Szwedko](https://forum.ansible.com/u/Jesse_Szwedko)\
**Post date:** [October 16, 2014, 12:20am UTC](https://forum.ansible.com/t/feature-idea-check-mode-for-callbacks/16524/1 "2014-10-16T00:20:07Z")

</div>

Hi all,

Proposing the following feature idea in the hopes that someone will tell me it’s already available.

We currently run all of our playbooks through `ansible-playbook -c` as part of automated testing. We also have a callback that depends on some environment configuration in the ` __init__ ` function. It would be nice if we could determine if we are running under `check_mode` in the callback to skip this validation (you could also see this being useful for callbacks with other behaviour during **init** ). This feature would be similar to how you can determine, in an Ansible module, if you are in check\_mode to change the behaviour.

-Jesse

---

<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:** [October 16, 2014, 1:25am UTC](https://forum.ansible.com/t/feature-idea-check-mode-for-callbacks/16524/2 "2014-10-16T01:25:08Z")

</div>

You should be able to achieve this by implementing some code that looks like:

def playbook\_on\_start(self):  
self.disabled = self.playbook.check

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 16, 2014, 4:54am UTC](https://forum.ansible.com/t/feature-idea-check-mode-for-callbacks/16524/3 "2014-10-16T04:54:38Z")

</div>

Callbacks are output mechanisms, so you wouldn’t be doing any validation in a callback.

Or at least, I’m not sure I know what validation you mean. Can you tell me more about what’s going in your custom callback?

---

<div class="post-metadata">

**Author:** ![Jesse\_Szwedko](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jesse\_Szwedko](https://forum.ansible.com/u/Jesse_Szwedko)\
**Post date:** [October 16, 2014, 2:14pm UTC](https://forum.ansible.com/t/feature-idea-check-mode-for-callbacks/16524/4 "2014-10-16T14:14:05Z")

</div>

Ah! Thank you Matt, I didn’t realize it’d be available via the playbook; I can move initialization there.

Michael, the custom callback is doing Hipchat notification (similar to [https://github.com/ansible/ansible/blob/devel/plugins/callbacks/hipchat.py](https://github.com/ansible/ansible/blob/devel/plugins/callbacks/hipchat.py)) and requires some environment variables to be set to run. If they aren’t set it outputs a warning (similar to the example plugin). We were just trying to avoid the warnings during `ansible-playbook -c`.

Thank you both!
