2019-10-06 20:55:56 +00:00
|
|
|
|
---
|
|
|
|
|
# Server/Cronmails: Setup Mails from Cronjobs (install exim)
|
|
|
|
|
|
|
|
|
|
# Install and configure exim
|
2020-03-08 15:41:55 +00:00
|
|
|
|
- name: cronmails - Install exim4
|
|
|
|
|
include_tasks: "{{ item }}"
|
|
|
|
|
with_first_found:
|
|
|
|
|
- "cronmails-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml"
|
|
|
|
|
- "cronmails-{{ ansible_distribution }}.yml"
|
|
|
|
|
- "cronmails-{{ ansible_os_family }}.yml"
|
|
|
|
|
|
|
|
|
|
# Configure exim
|
2019-10-06 20:55:56 +00:00
|
|
|
|
- name: cronmails - Create exim4 config folder
|
|
|
|
|
become: yes
|
2019-11-12 20:34:35 +00:00
|
|
|
|
file:
|
|
|
|
|
path: /etc/exim4
|
|
|
|
|
state: directory
|
2019-10-06 20:55:56 +00:00
|
|
|
|
- name: cronmails - Copy exim4 config template
|
|
|
|
|
become: yes
|
|
|
|
|
copy:
|
|
|
|
|
src: "{{ role_path }}/files/exim4.conf.template"
|
|
|
|
|
dest: /etc/exim4/exim4.conf.template
|
2019-11-30 17:37:34 +00:00
|
|
|
|
register: cronmails_conftmp_update
|
2019-10-06 20:55:56 +00:00
|
|
|
|
- name: cronmails - Copy exim4 config file
|
|
|
|
|
become: yes
|
|
|
|
|
template:
|
|
|
|
|
src: "{{ role_path }}/templates/update-exim4.conf.conf"
|
|
|
|
|
dest: /etc/exim4/update-exim4.conf.conf
|
2019-11-30 17:37:34 +00:00
|
|
|
|
register: cronmails_conffile_update
|
2019-10-06 20:55:56 +00:00
|
|
|
|
- name: cronmails - Run update-exim4.conf
|
|
|
|
|
become: yes
|
|
|
|
|
shell: "update-exim4.conf"
|
2019-11-30 17:37:34 +00:00
|
|
|
|
when: cronmails_conftmp_update.changed or cronmails_conffile_update.changed
|
2019-10-06 20:55:56 +00:00
|
|
|
|
- name: cronmails - Enable and start exim4
|
|
|
|
|
become: yes
|
|
|
|
|
service:
|
|
|
|
|
name: exim4
|
|
|
|
|
state: started
|
|
|
|
|
enabled: yes
|
|
|
|
|
|
|
|
|
|
# Set crobjob env variables/ settings
|
|
|
|
|
- name: cronmails - Crontab set path
|
|
|
|
|
become: yes
|
|
|
|
|
cron:
|
|
|
|
|
name: PATH
|
|
|
|
|
env: yes
|
|
|
|
|
value: /bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
|
|
|
|
|
- name: cronmails - Crontab set mailto
|
|
|
|
|
become: yes
|
|
|
|
|
cron:
|
|
|
|
|
name: MAILTO
|
|
|
|
|
env: yes
|
2019-11-12 20:06:04 +00:00
|
|
|
|
value: "{{ cron_email }}"
|