"Play recap" or current status programmatically available in task?

Hello,

I’d like to send a summary of the run (basically the play recap which is shown after playbook execution on the command line) to a hipchat room.

PLAY RECAP ******************************************************************** host1 : ok=8 changed=0 unreachable=0 failed=0 host2 : ok=8 changed=0 unreachable=0 failed=0 host3 : ok=8 changed=0 unreachable=0 failed=0

Is there a way how I could programmatically access the current status?

Thanks,

Daniel

The answer to accessing events programmatically is a callback plugin, and Matt Martz from Rackspace contributed one exactly for hipchat.

https://github.com/ansible/ansible/blob/devel/plugins/callbacks/hipchat.py

See the docs about callback plugins, but basically you just need to have this stored at a filesystem location and configure ansible.cfg to include the callback plugin directory that it is in, and it will load everything in that dir.

You may wish to modify the output it creates.

This is a way better way to share things in chat than the individual notification modules for things like this, as callbacks have an opportunity to see everything and it’s also going to be more efficient as they can limit the number of connections/disconnections involved in the chat server.

Thanks Michael,

I already worked with plugins but have totally overlooked the callback plugins. This rises followup question on my end but I will start a separate topic on that.

Thanks,
Daniel