2014-03-21 19:16:55 +00:00
|
|
|
---
|
2018-04-28 18:21:08 +00:00
|
|
|
# Deploy msmtp
|
2019-07-30 17:27:46 +00:00
|
|
|
|
|
|
|
# TODO:
|
2019-07-31 14:51:00 +00:00
|
|
|
# Fix: Check if mailserver is ready, as Test mail will only work,
|
|
|
|
# if msmtp is setup after the mailserver is already configured
|
2019-07-30 17:27:46 +00:00
|
|
|
|
2018-04-28 18:21:08 +00:00
|
|
|
- name: Update apt cache.
|
|
|
|
apt:
|
|
|
|
update_cache: yes
|
2019-07-31 14:51:00 +00:00
|
|
|
upgrade: "no"
|
2018-04-28 18:21:08 +00:00
|
|
|
cache_valid_time: 14400 # 4 hours
|
|
|
|
tags: mail
|
|
|
|
when: ansible_os_family == "Debian"
|
2014-03-21 19:16:55 +00:00
|
|
|
|
2018-04-28 18:21:08 +00:00
|
|
|
- name: Remove other MTAs.
|
|
|
|
apt:
|
2019-07-31 14:51:00 +00:00
|
|
|
name: "{{ packages }}"
|
2018-04-28 18:21:08 +00:00
|
|
|
state: absent
|
|
|
|
autoremove: yes
|
|
|
|
purge: yes
|
2019-07-31 14:51:00 +00:00
|
|
|
vars:
|
|
|
|
packages:
|
2018-04-28 18:21:08 +00:00
|
|
|
- exim4*
|
|
|
|
- postfix*
|
|
|
|
- sendmail*
|
|
|
|
tags:
|
|
|
|
- mail
|
2018-05-07 17:15:32 +00:00
|
|
|
when:
|
|
|
|
- msmtp_remove_mtas
|
|
|
|
- ansible_os_family == "Debian"
|
2018-04-28 18:21:08 +00:00
|
|
|
|
2018-05-07 08:31:19 +00:00
|
|
|
- name: Install msmtp and mailx on Debian.
|
2018-04-28 18:21:08 +00:00
|
|
|
apt:
|
2019-07-31 14:51:00 +00:00
|
|
|
name: "{{ packages }}"
|
2018-04-28 18:21:08 +00:00
|
|
|
state: present
|
2019-07-31 14:51:00 +00:00
|
|
|
vars:
|
|
|
|
packages:
|
2018-04-28 18:21:08 +00:00
|
|
|
- msmtp-mta
|
|
|
|
- bsd-mailx
|
|
|
|
tags: mail
|
|
|
|
notify: test mail
|
|
|
|
when: ansible_os_family == "Debian"
|
|
|
|
|
2018-05-08 11:57:20 +00:00
|
|
|
- name: Install msmtp and s-nail on Archlinux.
|
2019-07-31 14:51:00 +00:00
|
|
|
pacman:
|
|
|
|
name: "{{ packages }}"
|
|
|
|
state: present
|
|
|
|
vars:
|
|
|
|
packages:
|
2018-04-28 18:21:08 +00:00
|
|
|
- msmtp
|
|
|
|
- msmtp-mta
|
2018-05-08 11:57:20 +00:00
|
|
|
- s-nail
|
2018-04-28 18:21:08 +00:00
|
|
|
when: ansible_os_family == "Archlinux"
|
|
|
|
|
2018-05-26 14:12:37 +00:00
|
|
|
- name: Install msmtp and mailx on Alpine.
|
|
|
|
apk:
|
2019-07-31 14:51:00 +00:00
|
|
|
name: "{{ packages }}"
|
2018-05-26 14:12:37 +00:00
|
|
|
state: present
|
2019-07-30 17:27:46 +00:00
|
|
|
update_cache: no
|
2019-07-31 14:51:00 +00:00
|
|
|
vars:
|
|
|
|
packages:
|
|
|
|
- msmtp
|
|
|
|
- mailx
|
2018-05-26 14:12:37 +00:00
|
|
|
when: ansible_os_family == "Alpine"
|
|
|
|
|
|
|
|
- name: Overwrite busybox sendmail link to point to mSMTP.
|
|
|
|
file:
|
|
|
|
src: /usr/bin/msmtp
|
|
|
|
dest: /usr/sbin/sendmail
|
|
|
|
state: link
|
|
|
|
when: ansible_os_family == "Alpine"
|
|
|
|
|
2018-04-28 18:21:08 +00:00
|
|
|
- name: Copy mstprc conf file.
|
|
|
|
template:
|
|
|
|
src: msmtprc.j2
|
|
|
|
dest: /etc/msmtprc
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
tags: mail
|
|
|
|
notify: test mail
|
|
|
|
|
|
|
|
- name: Copy aliases conf file.
|
|
|
|
template:
|
|
|
|
src: aliases.j2
|
|
|
|
dest: /etc/aliases
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
tags: mail
|
|
|
|
notify: test mail
|