diff --git a/README.md b/README.md index a5d0586..6e8352a 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ None * `postfix_smtpd_tls_cert_file` [default: `/etc/ssl/certs/ssl-cert-snakeoil.pem`]: Path to certificate file * `postfix_smtpd_tls_key_file` [default: `/etc/ssl/certs/ssl-cert-snakeoil.key`]: Path to key file * `postfix_raw_options` [default: `[]`]: List of lines (to pass extra (unsupported) configuration) + * `postfix_master_custom` [default: Debian default master.cf]: Dictionary of master.cf lines with service and type together as key, separated by space ## Dependencies @@ -229,6 +230,20 @@ A simple example that shows how to add some raw config: policyd-spf_time_limit = 3600 ``` +A simple example that shows how to disable bounce mails with master_custom: + +```yaml +--- +- hosts: all + roles: + - postfix + vars: + postfix_master_custom: + bounce unix: '- - y - 0 discard' + defer unix: '- - y - 0 discard' + trace unix: '- - y - 0 discard' +``` + #### License MIT diff --git a/defaults/main.yml b/defaults/main.yml index 35ab0df..8f4e66b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -45,3 +45,43 @@ postfix_default_database_type: hash postfix_smtpd_tls_cert_file: /etc/ssl/certs/ssl-cert-snakeoil.pem postfix_smtpd_tls_key_file: /etc/ssl/private/ssl-cert-snakeoil.key postfix_raw_options: [] +postfix_master_custom: [] +postfix_master_default: + smtp inet: 'n - y - - smtpd' + pickup unix: 'n - y 60 1 pickup' + cleanup unix: 'n - y - 0 cleanup' + qmgr unix: 'n - n 300 1 qmgr' + tlsmgr unix: '- - y 1000? 1 tlsmgr' + rewrite unix: '- - y - - trivial-rewrite' + bounce unix: '- - y - 0 bounce' + defer unix: '- - y - 0 bounce' + trace unix: '- - y - 0 bounce' + verify unix: '- - y - 1 verify' + flush unix: 'n - y 1000? 0 flush' + proxymap unix: '- - n - - proxymap' + proxywrite unix: '- - n - 1 proxymap' + smtp unix: '- - y - - smtp' + relay unix: '- - y - - smtp' + showq unix: 'n - y - - showq' + error unix: '- - y - - error' + retry unix: '- - y - - error' + discard unix: '- - y - - discard' + local unix: '- n n - - local' + virtual unix: '- n n - - virtual' + lmtp unix: '- - y - - lmtp' + anvil unix: '- - y - 1 anvil' + scache unix: '- - y - 1 scache' + maildrop unix: '- n n - - pipe + flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}' + uucp unix: '- n n - - pipe + flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)' + ifmail unix: '- n n - - pipe + flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)' + bsmtp unix: '- n n - - pipe + flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient' + scalemail-backend unix: '- n n - 2 pipe + flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}' + mailman unix: '- n n - - pipe + flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py + ${nexthop} ${user}' +postfix_master: "{{ postfix_master_default | combine(postfix_master_custom) }}" diff --git a/tasks/main.yml b/tasks/main.yml index 0f74727..8e4d5d6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -57,6 +57,19 @@ - postfix - postfix-configuration +- name: update mastercf file + template: + src: "{{ postfix_master_cf.lstrip('/') }}.j2" + dest: "{{ postfix_master_cf }}" + owner: root + group: root + mode: 0644 + notify: restart postfix + tags: + - configuration + - postfix + - postfix-configuration + - name: configure sasl username/password template: src: "{{ postfix_sasl_passwd_file.lstrip('/') }}.j2" @@ -163,16 +176,12 @@ - postfix-recipient-canonical-maps - name: configure transport maps - lineinfile: + template: dest: "{{ postfix_transport_maps_file }}" - regexp: '^{{ item.pattern | regex_escape }}.*' - line: '{{ item.pattern }} {{ item.result }}' + src: "{{ postfix_transport_maps_file.lstrip('/') }}.j2" owner: root group: root mode: 0644 - create: true - state: present - with_items: "{{ postfix_transport_maps }}" notify: - postmap transport_maps - restart postfix diff --git a/templates/etc/postfix/master.cf.j2 b/templates/etc/postfix/master.cf.j2 new file mode 100644 index 0000000..d919401 --- /dev/null +++ b/templates/etc/postfix/master.cf.j2 @@ -0,0 +1,5 @@ +# {{ ansible_managed }} + +{% for item in postfix_master %} +{{ item }} {{ postfix_master[item] }} +{% endfor %} diff --git a/templates/etc/postfix/transport_maps.j2 b/templates/etc/postfix/transport_maps.j2 new file mode 100644 index 0000000..1efd3f6 --- /dev/null +++ b/templates/etc/postfix/transport_maps.j2 @@ -0,0 +1,6 @@ +{{ ansible_managed | comment }} + +{% for transport in postfix_transport_maps %} +{{ transport.pattern }} {{ transport.result }} +{% endfor %} + diff --git a/vars/main.yml b/vars/main.yml index 050326f..1a4b650 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -7,6 +7,7 @@ postfix_debconf_selections: vtype: select postfix_main_cf: /etc/postfix/main.cf +postfix_master_cf: /etc/postfix/master.cf postfix_mailname_file: /etc/mailname postfix_aliases_file: /etc/aliases postfix_virtual_aliases_file: /etc/postfix/virtual