# Dynamic callback

**URL:** <https://forum.ansible.com/t/dynamic-callback/15243>\
**Category:** Ansible Project\
**Created:** [May 15, 2014, 7:51am UTC](https://forum.ansible.com/t/dynamic-callback/15243 "2014-05-15T07:51:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adham\_H](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Adham\_H](https://forum.ansible.com/u/Adham_H)\
**Post date:** [May 15, 2014, 7:51am UTC](https://forum.ansible.com/t/dynamic-callback/15243/1 "2014-05-15T07:51:10Z")

</div>

Hey,

Is it possible to have play set a callback or that has to be done before the execution ?

---

<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:** [May 15, 2014, 11:28am UTC](https://forum.ansible.com/t/dynamic-callback/15243/2 "2014-05-15T11:28:40Z")

</div>

Ansible callbacks are not set by plays, they are loaded by being in the callback path prior to starting.

The path callbacks are searched for in is determined by ansible.cfg.

I think it may be interesting to discuss your fuctional use case as there may be a better way to achieve what you are looking for?

---

<div class="post-metadata">

**Author:** ![Adham\_H](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Adham\_H](https://forum.ansible.com/u/Adham_H)\
**Post date:** [May 15, 2014, 1:30pm UTC](https://forum.ansible.com/t/dynamic-callback/15243/3 "2014-05-15T13:30:47Z")

</div>

Thats what i do at the moment, but the idea is to set callback based on some variable that will then selectively enable callback or not during the execution of a play. So for examples on development deployment we do not need callback functionality on production we might need or while debugging.

I have not digged into the code but i think the hooks are done before execution and might make my request hard to achieve easily.

---

<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:** [May 15, 2014, 9:49pm UTC](https://forum.ansible.com/t/dynamic-callback/15243/4 "2014-05-15T21:49:35Z")

</div>

“but the idea is to set callback based on some variable that will then selectively enable callback or not during the execution of a play”

You could do some checks in the body of the callback functions that make the callbacks a no-op.
