Reporting "changed" state by email

210 views
Skip to first unread message

Anand Buddhdev

unread,
Jan 10, 2014, 3:13:28 AM1/10/14
to ansible...@googlegroups.com
Hello ansible folk,

We're running ansible mainly in the "pull" mode, and using the "local" connection type to run playbooks on our servers. It's configured to log to /var/log/ansible.log, and this file is rotated periodically by logrotate.

Are any of you using nay clever tricks to parse the log file and email output of just changed tasks back to a defined address? Id' love to be able to know when ansible has fixed something on one or more of my boxes.

Regards,

Anand

Jan-Piet Mens

unread,
Jan 10, 2014, 3:57:38 AM1/10/14
to ansible...@googlegroups.com
> Are any of you using nay clever tricks to parse the log file and email
> output of just changed tasks back to a defined address? Id' love to be able
> to know when ansible has fixed something on one or more of my boxes.

I think a callback plugin may be what you want, as you can 'trigger' on
all sorts of events.

Dag Wieers has written something which sounds to me as though it's just
what you need [1] and there are more examples at [2].

-JP

[1] https://github.com/ansible/ansible/blob/devel/plugins/callbacks/mail.py
[2] https://github.com/sfromm/ansible-plugins


Anand Buddhdev

unread,
Jan 10, 2014, 4:27:35 AM1/10/14
to ansible...@googlegroups.com
On Friday, 10 January 2014 09:57:38 UTC+1, JP Mens wrote:
Dag Wieers has written something which sounds to me as though it's just
what you need [1] and there are more examples at [2].


Thanks for these pointers JP. The mail plugin looks interesting, and is probably what I need. How do I call it from a playbook though? 

Jan-Piet Mens

unread,
Jan 10, 2014, 4:38:38 AM1/10/14
to ansible...@googlegroups.com
> Thanks for these pointers JP. The mail plugin looks interesting, and is
> probably what I need. How do I call it from a playbook though?

You don't -- that's the magic. :-)

You configure Ansible to use that callback plugin by dropping into the
directory you configure for callback plugins [1]. From that point on,
Ansible always invokes it automatically.

Forgive me for linking to my own blurb [2], but that's what I wrote at
the time. (I hope it's still more or less current.)

Good luck,

-JP

[1] http://docs.ansible.com/developing_plugins.html
[2] http://jpmens.net/2012/09/11/watching-ansible-at-work-callbacks/

Serge van Ginderachter

unread,
Jan 10, 2014, 5:09:30 AM1/10/14
to ansible...@googlegroups.com

On 10 January 2014 10:38, Jan-Piet Mens <jpm...@gmail.com> wrote:
that's the magic. :-)

​It's not magic, it's Cow Power.​

bryan hunt

unread,
Jan 10, 2014, 5:33:10 AM1/10/14
to ansible...@googlegroups.com

It would be nice if ansible-galaxy had support for distributing these sort of plugins.

Serge van Ginderachter

unread,
Jan 10, 2014, 6:13:22 AM1/10/14
to ansible...@googlegroups.com

On 10 January 2014 11:33, bryan hunt <picsol...@gmail.com> wrote:
It would be nice if ansible-galaxy had support for distributing these sort of plugins.

​+1​

Michael DeHaan

unread,
Jan 10, 2014, 7:58:46 AM1/10/14
to ansible...@googlegroups.com
It doesn't make sense to include in Galaxy as callbacks are not role based.

Effectively it would just make it an index of useful things on GitHub where already this is included in the main project.

Alternatively, what might be nice is shipping example plugins in a directory, such that they get installed alongside Ansible.




--
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.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Reply all
Reply to author
Forward
0 new messages