ansible-role-server/tasks/cronmails-Debian.yml

49 lines
1.4 KiB
YAML
Raw Normal View History

---
# Server/Cronmails: Setup Mails from Cronjobs (install exim) - Debian Version
# Install exim
- name: cronmails - Install exim4 as MTA
become: yes
ansible.builtin.apt:
name: "{{ packages }}"
state: present
vars:
packages:
- exim4
- mailutils
2020-03-08 16:56:50 +00:00
# Configure exim
- name: cronmails - Create exim4 config folder
become: yes
ansible.builtin.file:
2020-03-08 16:56:50 +00:00
path: /etc/exim4
state: directory
- name: cronmails - Copy exim4 config template
become: yes
ansible.builtin.copy:
2020-03-08 16:56:50 +00:00
src: "{{ role_path }}/files/exim4.conf.template"
dest: /etc/exim4/exim4.conf.template
register: cronmails_conftmp_update
- name: cronmails - Copy exim4 config file
become: yes
ansible.builtin.template:
2020-03-08 16:56:50 +00:00
src: "{{ role_path }}/templates/update-exim4.conf.conf"
dest: /etc/exim4/update-exim4.conf.conf
register: cronmails_conffile_update
- name: cronmails - Set /etc/mailname
become: yes
ansible.builtin.copy:
dest: /etc/mailname
content: "{{ exim_etc_mailname }}"
register: cronmails_mailname_update
2020-03-08 16:56:50 +00:00
- name: cronmails - Run update-exim4.conf
when: cronmails_conftmp_update.changed or cronmails_conffile_update.changed or cronmails_mailname_update.changed
2020-03-08 16:56:50 +00:00
become: yes
ansible.builtin.shell: "update-exim4.conf"
2020-03-08 16:56:50 +00:00
- name: cronmails - Enable and start exim4
become: yes
ansible.builtin.service:
2020-03-08 16:56:50 +00:00
name: exim4
state: restarted
2020-03-08 16:56:50 +00:00
enabled: yes