diff --git a/README.md b/README.md index 16530ba..b6d64b8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/group_vars/all b/group_vars/all index bf1b400..99fd9fd 100644 --- a/group_vars/all +++ b/group_vars/all @@ -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 diff --git a/roles/mail/files/cronie-service-msmtp.conf b/roles/mail/files/cronie-service-msmtp.conf new file mode 100644 index 0000000..a82731a --- /dev/null +++ b/roles/mail/files/cronie-service-msmtp.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/bin/crond -n -m '/usr/bin/msmtp -t' diff --git a/roles/mail/files/msmtprc b/roles/mail/files/msmtprc new file mode 100644 index 0000000..26245c5 --- /dev/null +++ b/roles/mail/files/msmtprc @@ -0,0 +1 @@ +aliases /etc/aliases diff --git a/roles/mail/tasks/main.yml b/roles/mail/tasks/main.yml index a9f70ac..b8c9150 100644 --- a/roles/mail/tasks/main.yml +++ b/roles/mail/tasks/main.yml @@ -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 diff --git a/roles/mail/tasks/msmtp.yml b/roles/mail/tasks/msmtp.yml new file mode 100644 index 0000000..b71d5eb --- /dev/null +++ b/roles/mail/tasks/msmtp.yml @@ -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