ansible-msmtp-mailer/tasks/main.yml

76 lines
1.6 KiB
YAML
Raw Normal View History

2014-03-21 19:16:55 +00:00
---
# Deploy msmtp
# TODO:
# Fix: Check if mailserver is ready, as Test mail will only work,
# if msmtp is setup after the mailserver is already configured
2021-05-15 15:20:39 +00:00
- name: Copy RPM file to server
copy:
src: msmtp-1.8.14-1.el8.x86_64.rpm
dest: /tmp/msmtp-1.8.14-1.el8.x86_64.rpm
when: ansible_os_family == "RedHat"
2014-03-21 19:16:55 +00:00
2021-05-15 15:20:39 +00:00
- name: Copy systemd unit file to server
copy:
src: msmtpd.service
dest: /etc/systemd/system/msmtpd.service
when: ansible_os_family == "RedHat"
2021-05-15 15:20:39 +00:00
- name: enable daemon
ansible.builtin.systemd:
name: msmtpd
enabled: yes
masked: no
daemon_reload: yes
when: ansible_os_family == "RedHat"
2021-05-15 15:20:39 +00:00
- name: Install msmtp
yum:
name:
- /tmp/msmtp-1.8.14-1.el8.x86_64.rpm
- mailx
state: present
2021-05-15 15:20:39 +00:00
disable_gpg_check: yes
when: ansible_os_family == "RedHat"
2021-05-15 15:20:39 +00:00
- name: Ensure group "msmtp" exists
group:
name: msmtp
2018-05-26 14:12:37 +00:00
state: present
2021-05-15 15:20:39 +00:00
when: ansible_os_family == "RedHat"
2018-05-26 14:12:37 +00:00
- name: Copy mstprc conf file.
template:
src: msmtprc.j2
dest: /etc/msmtprc
owner: root
2021-05-15 15:20:39 +00:00
group: msmtp
mode: 0640
tags: mail
2021-05-15 15:20:39 +00:00
notify:
- test mail
- restart msmtpd
- name: Copy aliases conf file.
template:
2021-05-15 15:20:39 +00:00
src: aliases-rhel.j2
dest: /etc/aliases
owner: root
group: root
mode: 0644
tags: mail
2021-05-15 15:20:39 +00:00
notify:
- test mail
- restart msmtpd
when: ansible_os_family == "RedHat"
- name: Copy sysconfig file.
template:
src: sysconfig.j2
dest: /etc/sysconfig/msmtpd
notify:
- test mail
- restart msmtpd
when: ansible_os_family == "RedHat"