From 39e1ebc616ad2e835c94f5e739cfc447b2dfef2a Mon Sep 17 00:00:00 2001 From: Michael Wilson Date: Fri, 25 Nov 2022 00:44:16 +0100 Subject: [PATCH] add debian mail relay setup --- common/mailrelay/tasks/debian.yml | 32 +++++++++++++++++++++++++++++++ common/mailrelay/tasks/main.yml | 6 ++++++ 2 files changed, 38 insertions(+) create mode 100644 common/mailrelay/tasks/debian.yml diff --git a/common/mailrelay/tasks/debian.yml b/common/mailrelay/tasks/debian.yml new file mode 100644 index 0000000..63e9ae5 --- /dev/null +++ b/common/mailrelay/tasks/debian.yml @@ -0,0 +1,32 @@ +- name: install libsasl2-modules + package: + name: libsasl2-modules + state: latest + +- name: deploy mail relay secrets + template: + src: postfix_secrets + dest: /etc/postfix/secrets + owner: root + group: root + mode: 0600 + notify: postmap + +- name: configure mailrelay + lineinfile: + dest: /etc/postfix/main.cf + state: present + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" + loop: + - line: "relayhost = [{{ mailrelay_host }}]:{{ mailrelay_port }}" + regexp: '^(\s*)relayhost(\s*)=.*$' + - line: "smtp_sasl_auth_enable = yes" + regexp: '^(\s*)smtp_sasl_auth_enable(\s*)=.*$' + - line: "smtp_sasl_password_maps = hash:/etc/postfix/secrets" + regexp: '^(\s*)smtp_sasl_password_maps(\s*)=.*$' + - line: "smtp_sasl_security_options = noanonymous" + regexp: '^(\s*)smtp_sasl_security_options(\s*)=.*$' + - line: "inet_interfaces = 127.0.0.1" + regexp: '^(\s*)inet_interfaces(\s*)=.*$' + notify: postfix_reload diff --git a/common/mailrelay/tasks/main.yml b/common/mailrelay/tasks/main.yml index 9eff319..220db82 100644 --- a/common/mailrelay/tasks/main.yml +++ b/common/mailrelay/tasks/main.yml @@ -10,3 +10,9 @@ when: ansible_distribution|lower == 'ubuntu' vars: ansible_become: yes + +- name: Debian mailrelay setup + include_tasks: ubuntu.yml + when: ansible_distribution|lower == 'debian' + vars: + ansible_become: yes