forward system mail to user

This commit is contained in:
Pig Monkey 2015-12-22 18:27:42 -08:00
parent ff0c73b15d
commit 72a5591aec
6 changed files with 55 additions and 3 deletions

View file

@ -61,6 +61,12 @@ AUR packages are installed via the [ansible-aur][7] module. Note that while
[aura][8], an [AUR helper][9], is installed by default, it will *not* be used
during any of the provisioning.
## System Mail
If the `email.user` variable is defined, the system will be configured to
forward mail for the user and root to this address. Removing this variable will
cause no mail aliases to be put in place.
## Known Issues
* [tpfanco][10], normally installed as part of the `thinkpad` role is currently

View file

@ -2,6 +2,7 @@ user:
name: pigmonkey
group: pigmonkey
shell: /usr/bin/zsh
email: peter@havenaut.net
dotfiles:
url: git@github.com:pigmonkey/dotfiles.git

View file

@ -0,0 +1,3 @@
[Service]
ExecStart=
ExecStart=/usr/bin/crond -n -m '/usr/bin/msmtp -t'

1
roles/mail/files/msmtprc Normal file
View file

@ -0,0 +1 @@
aliases /etc/aliases

View file

@ -12,10 +12,8 @@
- name: Install OfflineIMAP
pacman: name=offlineimap state=present
- name: Install msmtp
pacman: name=msmtp-mta state=present
- name: Install notmuch
pacman: name=notmuch state=present
- include: msmtp.yml
- include: contacts.yml

View file

@ -0,0 +1,43 @@
---
- name: Install msmtp
pacman: name=msmtp-mta state=present
tags:
- msmtp
- name: Push msmtp configuration file
copy: src=msmtprc dest=/etc/msmtprc
tags:
- msmtp
- name: Verify alias file exists
file: path=/etc/aliases state=touch
tags:
- msmtp
- name: Set root email alias
lineinfile: "dest=/etc/aliases
regexp=^root
state=present
line='root: {{ user.email }}'"
when: user.email
tags:
- msmtp
- name: Set user email alias
lineinfile: "dest=/etc/aliases
regexp=^{{ user.name }}
state=present
line='{{ user.name }}: {{ user.email }}'"
when: user.email
tags:
- msmtp
- name: Create cronie systemd unit file directory
file: path=/etc/systemd/system/cronie.service.d state=directory
tags:
- msmtp
- name: Override cronie send mail via msmtp
copy: src=cronie-service-msmtp.conf dest=/etc/systemd/system/cronie.service.d/msmtp.conf
tags:
- msmtp