Sending email notifications to group once playbook is executed

27 views
Skip to first unread message

Balaji

unread,
Mar 17, 2018, 11:12:27 AM3/17/18
to Ansible Project
Hello Everyone..!


I have a scenario where I have to send an email to a group of people based on playbook completion.


Site.yml - > master playbook consists of all individual playbook.

app1.yml
app2.yml
app3.yml

host file -
app1_host
SERVER1

app2_host
SERVER2

app3_host
SERVER3



1) I have app1.yml  which calls roles to perform series of task on SERVER1. app2.yml to call same roles to perform same set of tasks on SERVER2
I can include email module in roles at the end to send an email once all the tasks are completed.


But 

2) I have site.yml ( master playbook) which calls multiple playbooks like 

app1.yml 
app2.yml
app3.yml 

Now, when site.yml calls app1.yml => tasks are execute => email sent.
                   site.yml calls app2.yml => tasks are execute => email sent.
                   site.yml calls app3.yml => tasks are execute => email sent.     


How can I achieve to make ansible to send email only once if site.yml is called  OR at end site.yml tasks are completed? 

Any suggestion..!


Thanks,
Balaji Chavdi 












Kai Stian Olstad

unread,
Mar 18, 2018, 8:03:41 AM3/18/18
to ansible...@googlegroups.com
On Saturday, 17 March 2018 16.12.27 CET Balaji wrote:

> How can I achieve to make ansible to send email only once if site.yml is
> called OR at end site.yml tasks are completed?
>
> Any suggestion..!

Add a play in bottom of site.yml that sends the mail.


--
Kai Stian Olstad

Brian Coca

unread,
Mar 19, 2018, 2:25:19 PM3/19/18
to Ansible Project
there is also the mail callback plugin



--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages