summaryrefslogtreecommitdiff
path: root/roles/mail/postfix/mx/tasks/main.yml
blob: 5ef5ff42ebcf78edbe4185f6c5561bd16150024d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
- name: configure TLS
  when: postfix_mx_tls is defined
  block:
  - name: generate/install/fetch TLS certificate
    vars:
      x509_certificate_name: "postfix-{{ postfix_mx_hostname }}"
      x509_certificate_config: "{{ postfix_mx_tls.certificate_config | default({}) }}"
      x509_certificate_hostnames:
      - "{{ postfix_mx_hostname }}"
      x509_certificate_reload_services:
      - postfix
    include_role:
      name: "x509/{{ postfix_mx_tls.certificate_provider }}/cert"

## TODO: configure virtual and relay domains and maps

- name: configure spam filtering using rspamd
  when: postfix_mx_spam_filter == "rspamd"
  block:
  - name: add postfix user to rspamd group
    user:
      name: postfix
      groups: _rspamd
      append: yes
    notify: restart postfix

  - name: configure postfix milter config for rspamd
    vars:
      postfix_options:
        milter_protocol: "6"
        milter_default_action: "accept"
        smtpd_milters: "unix:rspamd/rspamd-proxy.sock"
        non_smtpd_milters: "unix:rspamd/rspamd-proxy.sock"
    loop: "{{ postfix_options | dict2items }}"
    loop_control:
      label: "{{ item.key }} = {{ item.value }}"
    lineinfile:
      regexp: "^#?\\s*{{ item.key }}\\s*="
      line: "{{ item.key }} = {{ item.value }}"
      dest: /etc/postfix/main.cf
    notify: restart postfix