Collect playbook results

hi,

we currently use ansible with a playbook to install software packages on many servers. the installation is a vendor specific shell-script and we need the output of this script. currently i use the “mail” action to send the output, but with many hosts in my inventory i’m sending many mails.

is there an option to execute a task (or something similar) after all hosts have their tasks done? and do i have access to their registered variables like a “task_variables” list where i can iterate over?

thanks

Probably the best option is you could write a callback plugin that sends an email. We actually have an example of this that would run when a playbook completes:

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

See the docs for info about writing callback plugins if interested, but basically you would drop this int he callback plugin path as configured in ansible.cfg.

Hope that helps!

you may wish to adapt the script to your particular needs.