Send email and sms using ansible.

Send email and sms using ansible.

Step 1: Install ansible using

yum install ansible -y

Step 2: Create yml file for sending email with vim email.yml command.

Code for email.yml playbook.

- hosts: localhosttasks: - name: Sending Mail community.general.mail: host: smtp.gmail.comport: 465 sender: "************.ac.in" recipients: "*********@gmail.com" subject: "Test mail from Ansible-Playbook" body: "Hi! This mail is sent from Ansible Playbook" username: "************.ac.in" password: "ti**************tz"

Step 3. Run command ansible-playbook email.yml for sending mail.

For sending sms

Step 1: Make a sms.yml file using vim sms.yml command.

- hosts: localhosttasks: - name: "Sending SMS" community.general.twilio: account_sid: "ACed********************4f24" auth_token: "6b9***************c7d" from_number: "+1*******5" msg: "Hi! This is a test message from Ansible using Twilio." to_numbers: "+91**********2"

Run ansible-playbook sms.yml for sending sms.