E-mails
The easiest and most common way of alerting people is to send e-mails. Ansible allows you to send e-mails from your playbook using a mail
module. You can use this module in between any of your tasks and notify your user whenever required. Also, in some cases, you cannot automate each and every thing because either you lack the authority or it requires some manual checking and confirmation. If this is the case, you can notify the responsible user that Ansible has done its job and it's time for him/her to perform his/her duty. Let's see how you can use the mail
module to notify your users with a very simple playbook called uptime_and_email.yaml
:
- hosts: localhost tasks: - name: Read the machine uptime command: uptime -p register: uptime - name: Send the uptime via e-mail mail: host: mail.fale.io username: ansible@fale.io password: PASSWORD ...