From 85b3d2a16b5cfbb499a4ebcb88967dcdc334cf21 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 1 Nov 2018 11:04:21 +0100 Subject: o Adding postfix role, enabling for knot. --- ansible/roles/postfix/tasks/main.yml | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 ansible/roles/postfix/tasks/main.yml (limited to 'ansible/roles/postfix/tasks/main.yml') diff --git a/ansible/roles/postfix/tasks/main.yml b/ansible/roles/postfix/tasks/main.yml new file mode 100644 index 0000000..31ff3a2 --- /dev/null +++ b/ansible/roles/postfix/tasks/main.yml @@ -0,0 +1,47 @@ +- tags: postfix-config + become: yes + block: + - name: "Configure postfix: main.cf" + notify: reload postfix + with_items: + - key: "smtp_sasl_auth_enable" + value: "yes" + - key: "smtp_sasl_password_maps" + value: "hash:/etc/postfix/sasl_passwd" + - key: "smtp_sasl_security_options" + value: "noanonymous" + - key: "smtp_tls_security_level" + value: "{{ 'encrypt' if postfix__is_satellite else 'may' }}" + lineinfile: + dest: /etc/postfix/main.cf + line: "{{ item.key }} = {{ item.value }}" + regexp: "^{{ item.key }} =" + - name: "Configure postfix: main.cf (relayhost)" + when: postfix__relayhost is defined + notify: reload postfix + with_items: + - key: "relayhost" + value: "{{ postfix__relayhost }}" + lineinfile: + dest: /etc/postfix/main.cf + line: "{{ item.key }} = {{ item.value }}" + regexp: "^{{ item.key }} =" + +- tags: postfix-config + when: postfix__sasl_password is defined + become: yes + block: + - name: Create /etc/postfix/sasl_passwd + copy: + dest: /etc/postfix/sasl_passwd + content: "" + force: no + mode: 0600 + + - name: "Configure postfix: sasl_passwd" + notify: postmap /etc/postfix/sasl_passwd + with_items: "{{ postfix__sasl_password }}" + lineinfile: + dest: /etc/postfix/sasl_passwd + line: "{{ item.host }} {{ item.username }}:{{ item.password }}" + regexp: "^{{ item.host|regex_escape() }}" -- cgit v1.2.3