Initial msmtp implementation

This commit is contained in:
KemoNine 2020-08-04 22:51:58 +00:00
parent f7420219ee
commit 1c4b0e8cf8
4 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,13 @@
---
#######################################
# General settings
#######################################
# E-mail address for notifications
msmtp_email_address: "user@domain.tld"
# SMTP server config options
msmtp_smtp_server: "email.domain.tld"
msmtp_smtp_from: "user@domain.tld"
msmtp_smtp_user: "user@domain.tld"
msmtp_smtp_password: "password"

View File

@ -0,0 +1,40 @@
---
- name: Gather instance facts
setup:
- name: Update APT package cache
apt:
update_cache: "{{ wireguard_ubuntu_update_cache }}"
cache_valid_time: "{{ wireguard_ubuntu_cache_valid_time }}"
tags:
- msmtp-install
- name: Install msmtp
package:
name: "{{ packages }}"
state: present
vars:
packages:
- msmtp
- msmtp-mta
- ca-certificates
tags:
- msmtp-install
- block:
- name: Generate msmtp configuration file
template:
src: msmtp
dest: "/etc/msmtprc"
owner: root
group: root
mode: 0644
tags:
- msmtp-config
- name: Generate aliases configuration file
template:
src: aliases
dest: "/etc/aliases"
owner: root
group: root
mode: 0644
tags:
- msmtp-config

View File

@ -0,0 +1,10 @@
# Example aliases file
# Send root to Joe and Jane
root: {{ msmtp_email_address }}
# Send cron to Mark
cron: {{ msmtp_email_address }}
# Send everything else to admin
default: {{ msmtp_email_address }}

View File

@ -0,0 +1,22 @@
# Accounts will inherit settings from this section
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp.log
from {{ msmtp_smtp_from }}
keepbcc on
account piframe
host {{ msmtp_smtp_server }}
port 587
auth on
user {{ msmtp_smtp_user }}
password {{ msmtp_smtp_password }}
# Set a default account
account default : piframe
aliases /etc/aliases