Ansible is providing many types of modules for the automation process, this post let starts with sends an email to the developers or others once the application is deployed to the different environments. Will use mail module and it is useful for sending emails from playbooks.
Note: Refer the link to install Ansible: https://www.thelinuxfaq.com/639-how-to-install-ansible-on-ubuntu-18-04
- hosts: localhost
become: yes
become_user: USER_NAME
gather_facts: false
connection: local
vars:
new_line: "\n"
##>> Sending email to team
- mail:
host: 127.0.0.1
port: 25
subject: [$ENV] Deployment status of $SERVICE service
body: Hi Team, {{new_line}}{{new_line}}We have deployed $APP_NAME application to the $ENV environment. Please do the sanity test.{{new_line}}{{new_line}}Thank you!,{{new_line}}DevOps team.{{new_line}}
from: from@yourdomain.com
to: TO_USER1 <to@yourdomain.com>
cc: TO_USER2 <user2@yourdomain.com>
headers: 'Reply-To=to@yourdomain.com|X-Special="Reports"'
charset: utf8
delegate_to: localhost
become: yes
become_user: USER_NAME
gather_facts: false
connection: local
vars:
new_line: "\n"
##>> Sending email to team
- mail:
host: 127.0.0.1
port: 25
subject: [$ENV] Deployment status of $SERVICE service
body: Hi Team, {{new_line}}{{new_line}}We have deployed $APP_NAME application to the $ENV environment. Please do the sanity test.{{new_line}}{{new_line}}Thank you!,{{new_line}}DevOps team.{{new_line}}
from: from@yourdomain.com
to: TO_USER1 <to@yourdomain.com>
cc: TO_USER2 <user2@yourdomain.com>
headers: 'Reply-To=to@yourdomain.com|X-Special="Reports"'
charset: utf8
delegate_to: localhost
Comments (0)