This ansible role deploys msmtp as a mailer for Debian, Ubuntu, Arch & Alpine Linux
- Access to a functioning SMTP server.
- Either use github to clone/download into your roles directory:
git clone https://github.com/chriswayg/ansible-msmtp-mailer.git
- Or use ansible galaxy:
ansible-galaxy install chriswayg.msmtp-mailer
All the default variables are located defaults/main.yml. Mostly you would need to configure the following variables.
-
msmtp_accounts: You can define one or more smtp accounts:
msmtp_accounts: - account: gmail host: smtp.gmail.com port: 587 auth: "on" from: [email protected] user: [email protected] password: "some password" - account: mysmtp host: smtp.example port: 587 auth: "on" from: [email protected] user: [email protected] password: plain-text-password2 tls_starttls: "off"
-
msmtp_default_account: Default smtp account to use
msmtp_default_account: "gmail"
-
Logging
-
Option A (syslog)
msmtp_log : "syslog"
-
Option B (file logging)
msmtp_log : "file" msmtp_logfile : /var/log/msmtp.log
-
Option C (No logging)
msmtp_log : "no"
-
-
Mail aliases
-
msmtp_alias_default: default email this required
msmtp_alias_default : [email protected]
-
msmtp_alias_root: root email this is optional
msmtp_alias_root : [email protected]
-
msmtp_alias_cron: cron email this optional
msmtp_alias_cron : [email protected]
-
-
Configuration file permissions
-
msmtprc_owner: owner of /etc/msmtprc, default
root
msmtprc_owner : root
-
msmtprc_group: group of /etc/msmtprc, default
root
msmtprc_group : root
-
msmtprc_mode: group of /etc/msmtprc, default
0644
msmtprc_mode : 0644
-
You can configure your variables in ansible with one of the following
- Create a variable in host/group variables directory.
- Editing vars/main.yml
- Run ansible-playbook with -e
- Edit the defaults/main.yml (not recommended)
---
- hosts: all
roles:
- ansible-msmtp-mailer
-
mstmp used to function out of the box with the provided defaults/main.yml settings, because the configuration used a real smtp server for testing, but Yandex does not allow this any more. Instead use a Gmail account for testing.
ansible-playbook -l hostname msmtp.yml
You should get a test mail if it works as expected on the root mail
- Forked from GitHub - AutomationWithAnsible/ansible-msmtp: Ansible MSTMP
- By Adham Helal
- Christian Wagner
- Apache 2.0