Find a file
2019-08-05 14:52:18 +08:00
defaults moved functioning email config from defaults to vars 2019-08-05 14:51:31 +08:00
handlers Auto stash before merge of "master" and "origin/master" 2018-05-08 19:57:20 +08:00
meta Add Alpine linux 2018-05-26 22:12:37 +08:00
tasks fix Ansible warnings about apt loops, etc 2019-07-31 22:51:00 +08:00
templates Edit comments 2018-05-07 16:31:19 +08:00
tests Enable test mail by default; disable on travis 2018-05-08 20:18:28 +08:00
vars moved functioning email config from defaults to vars 2019-08-05 14:51:31 +08:00
.gitignore Update gitignore 2018-05-07 16:28:48 +08:00
.travis.yml added Debian 10 2019-08-05 14:50:30 +08:00
LICENSE Update meta and readme 2018-05-07 22:28:10 +08:00
README.md Added example playbook. 2019-08-05 14:52:18 +08:00
Vagrantfile add RancherOS 2019-07-31 01:28:06 +08:00

Build Status

chriswayg.msmtp-mailer

This ansible role deploys msmtp as a mailer for Debian, Ubuntu, Arch & Alpine Linux

Prerequisite

  • Access to a functioning SMTP server.

How to install

  • Either use github to clone/dwonload into your roles directory:
    • git clone https://github.com/chriswayg/ansible-etckeeper.git
  • Or use ansible galaxy:
    • ansible-galaxy install chriswayg.msmtp-mailer

Variables

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:      example@gmail.example
      user:      example@gmail.example
      password:  "some password"
    - account:   mysmtp
      host:      smtp.example
      port:      587
      auth:      "on"
      from:      admin@example.org
      user:      myuser@example.org
      password:  plain-text-password2
    
  • 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 : ops@example.com

    • msmtp_alias_root: root email this is optional

      msmtp_alias_root : root@example.com

    • msmtp_alias_cron: cron email this optional

      msmtp_alias_cron : cron@example.com

Configure

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)

Example Playbook

---
- hosts: all
  roles:
    - chriswayg.msmtp-mailer

Run

By default mstmp will function out of the box with the defaults/main.yml settings, because the configuration uses a real smtp server (for testing only!)

ansible-playbook -l hostname msmtp.yml

Test

You should get a test mail if it works as expected on the root mail

Documentation

msmtp manual