ansible-msmtp-mailer/tasks/main.yml
2018-05-07 16:31:19 +08:00

63 lines
1.2 KiB
YAML
Executable file

---
# Deploy msmtp
- name: Update apt cache.
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 14400 # 4 hours
tags: mail
when: ansible_os_family == "Debian"
- name: Remove other MTAs.
apt:
pkg: "{{ item }}"
state: absent
autoremove: yes
purge: yes
with_items:
- exim4*
- postfix*
- sendmail*
tags:
- mail
- name: Install msmtp and mailx on Debian.
apt:
pkg: "{{item}}"
state: present
with_items:
- msmtp-mta
- bsd-mailx
tags: mail
notify: test mail
when: ansible_os_family == "Debian"
# not tested my modifications with Archlinux
- name: Install msmtp and mailx on Archlinux.
pacman: name={{item}} state=present
with_items:
- msmtp
- msmtp-mta
- mailutils
when: ansible_os_family == "Archlinux"
- 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