From 574916dfaf0a3a80c858cbca1e9bded98fdc885d Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Wed, 2 Sep 2020 17:13:13 +0000 Subject: [PATCH] postfix: Fix local mail delivery to relayhost --- roles/postfix/tasks/main.yml | 40 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/roles/postfix/tasks/main.yml b/roles/postfix/tasks/main.yml index 34e6cb3..4f93a99 100644 --- a/roles/postfix/tasks/main.yml +++ b/roles/postfix/tasks/main.yml @@ -17,6 +17,26 @@ line: "myhostname = {{ inventory_hostname }}" notify: restart postfix +- name: configure myorigin + lineinfile: + path: /etc/postfix/main.cf + regexp: '^myorigin\s*=' + insertafter: '^#myorigin\s*=' + line: "myorigin = {{ mail_domain }}" + notify: restart postfix + when: mail_domain is defined + +- name: configure mydestination + lineinfile: + path: /etc/postfix/main.cf + regexp: '^mydestination\s*=' + insertafter: '^#mydestination\s*=' + line: 'mydestination = ""' + notify: restart postfix + when: + - mail_domain is defined + - mail_server is defined + - name: configure relayhost lineinfile: path: /etc/postfix/main.cf @@ -26,24 +46,6 @@ notify: restart postfix when: mail_server is defined -- name: configure masquerade_classes - lineinfile: - path: /etc/postfix/main.cf - regexp: '^masquerade_classes\s*=' - insertafter: '^#?relayhost\s*=' - line: "masquerade_classes = envelope_sender" - notify: restart postfix - when: mail_domain is defined - -- name: configure masquerade_domains - lineinfile: - path: /etc/postfix/main.cf - regexp: '^masquerade_domains\s*=' - insertafter: '^masquerade_classes\s*=' - line: "masquerade_domains = {{ mail_domain }}" - notify: restart postfix - when: mail_domain is defined - - name: configure smtp_tls_security_level lineinfile: path: /etc/postfix/main.cf @@ -53,7 +55,7 @@ notify: restart postfix when: mail_server is defined -- name: configure smtp_tls_security_level +- name: configure smtp_tls_wrappermode lineinfile: path: /etc/postfix/main.cf regexp: '^smtp_tls_wrappermode\s*='