# (Developers) better callback context (upgrades in 1.1)

**URL:** <https://forum.ansible.com/t/developers-better-callback-context-upgrades-in-1-1/12585>\
**Category:** Ansible Project\
**Created:** [March 26, 2013, 3:02am UTC](https://forum.ansible.com/t/developers-better-callback-context-upgrades-in-1-1/12585 "2013-03-26T03:02:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [March 26, 2013, 3:02am UTC](https://forum.ansible.com/t/developers-better-callback-context-upgrades-in-1-1/12585/1 "2013-03-26T03:02:11Z")

</div>

I've added some new features to the API callbacks.

> From a given callback instance, the following member variables \*MAY\*

be set at various points in time.

You should use getattr in case things are not yet set at the point you  
use them, or if you are using the same callbacks for /usr/bin/ansible  
and /usr/bin/ansible-playbook.

self.play # the current play object  
self.playbook # the current playbook object  
self.runner # the current runner object  
self.task # the current task or handler object (set to None  
while running the setup task)

This is needed for, among other things, writing some really good  
callbacks for Ansible Commander logging, but I imagine anyone writing  
custom callbacks  
can make immediate use of this.

A getattr example for code inside a playbook would look like this:

play = getattr(self, 'play', None)

Let me know if there are any questions!

--Michael
