Run a logging task after Playbook ends?

591 views
Skip to first unread message

Michael Mahemoff

unread,
Mar 15, 2014, 6:15:53 PM3/15/14
to ansible...@googlegroups.com
Is there any way to run a command after the playbook has finished running, so it would run once no matter how many hosts were processed? Kind of a callback handler or "super-notifier".

I have a Hipchat message generated after deploying and I'd rather see one summary message than a line for each deployed host.

Michael DeHaan

unread,
Mar 15, 2014, 8:19:56 PM3/15/14
to ansible...@googlegroups.com
Yes, there's a callback mechanism for this, where you can configure callback plugins in ansible.cfg (or the environment) and intercept arbitrary events.

This was an example:


(Though the log_plays setting in ansible.cfg basically does this now, making this above plugin mostly optional)

This one is more entertaining:


So yes, you could definitely route this to hipchat instead of using the notification plugin.

Should you develop a cool script for hipchat, send us a pull request and we can ship it in the callbacks/ dir!




On Sat, Mar 15, 2014 at 6:15 PM, Michael Mahemoff <mic...@mahemoff.com> wrote:
Is there any way to run a command after the playbook has finished running, so it would run once no matter how many hosts were processed? Kind of a callback handler or "super-notifier".

I have a Hipchat message generated after deploying and I'd rather see one summary message than a line for each deployed host.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6370e80b-c700-4b72-8489-97876588e6ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matt Martz

unread,
Mar 15, 2014, 8:22:53 PM3/15/14
to ansible...@googlegroups.com, Michael DeHaan
I actually have a pull request submitted to supply a hipchat callback plugin:


The callback method of significance is `playbook_on_stats`

This is the callback method I use to send a hipchat notification that provides statistics about results at the end of the playbook run.
-- 
Matt Martz
ma...@sivel.net

Brian Coca

unread,
Mar 15, 2014, 8:24:39 PM3/15/14
to ansible...@googlegroups.com
you can also have a task or play at the end of your playbook that uses the existing hipchat notification module.

<your current playbook>

- hosts: localhost
  tasks:
     - hipchat: ....




--
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

Michael Mahemoff

unread,
Mar 16, 2014, 6:29:54 AM3/16/14
to ansible...@googlegroups.com
Thanks everyone, I'm glad there's a mechanism for this and I'll definitely test-run Matt's new plugin.
Reply all
Reply to author
Forward
0 new messages