From d6fee609e44e83193622439d7002307bf4d6bb18 Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Sat, 25 Sep 2021 23:16:31 +0200 Subject: [PATCH] Cronmails: Fix rejected mails b/c of non FQDNs in sender --- README.md | 1 + defaults/main.yml | 2 ++ tasks/cronmails-Debian.yml | 10 ++++++++-- tasks/cronmails.yml | 7 +++++++ templates/update-exim4.conf.conf | 2 +- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b0f6cf..10c9e19 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Mandatory variable: ### Cronmails Mandatory variable: - `cron_email`: Sender email address used by cron +- `exim_etc_mailname`: Exim4 /etc/mailname (default: inventory_hostname) ### Docker Optional variable: diff --git a/defaults/main.yml b/defaults/main.yml index a9ccf24..a6767f3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,3 +11,5 @@ telegraf_unifi_file: "telegraf-UniFi.conf.j2" telegraf_airmax_file: "telegraf-AirMAX.conf.j2" dockercompose_use_pip: false + +exim_etc_mailname: "{{ inventory_hostname }}" diff --git a/tasks/cronmails-Debian.yml b/tasks/cronmails-Debian.yml index 224eb5b..065a5f4 100644 --- a/tasks/cronmails-Debian.yml +++ b/tasks/cronmails-Debian.yml @@ -30,13 +30,19 @@ 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 - name: cronmails - Run update-exim4.conf become: yes ansible.builtin.shell: "update-exim4.conf" - when: cronmails_conftmp_update.changed or cronmails_conffile_update.changed + when: cronmails_conftmp_update.changed or cronmails_conffile_update.changed or cronmails_mailname_update.changed - name: cronmails - Enable and start exim4 become: yes ansible.builtin.service: name: exim4 - state: started + state: restarted enabled: yes diff --git a/tasks/cronmails.yml b/tasks/cronmails.yml index 0107780..46c3b59 100644 --- a/tasks/cronmails.yml +++ b/tasks/cronmails.yml @@ -23,3 +23,10 @@ name: MAILTO env: yes value: "{{ cron_email }}" +- name: cronmails - Add monthly test mail + become: yes + ansible.builtin.cron: + name: "Monthly Test Mail" + minute: "0" + day: "1" + job: echo "Monthly cron test mail" diff --git a/templates/update-exim4.conf.conf b/templates/update-exim4.conf.conf index 8075338..1837a6a 100644 --- a/templates/update-exim4.conf.conf +++ b/templates/update-exim4.conf.conf @@ -17,7 +17,7 @@ # This is a Debian specific file dc_eximconfig_configtype='internet' -dc_other_hostnames='{{ ansible_hostname }}, localhost.localdomain, localhost' +dc_other_hostnames='{{ inventory_hostname }}, localhost.localdomain, localhost' dc_local_interfaces='127.0.0.1 ; ::1' dc_readhost='' dc_relay_domains=''