Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}"
21 changes: 15 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions templates/etc/postfix/master.cf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# {{ ansible_managed }}

{% for item in postfix_master %}
{{ item }} {{ postfix_master[item] }}
{% endfor %}
6 changes: 6 additions & 0 deletions templates/etc/postfix/transport_maps.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ ansible_managed | comment }}

{% for transport in postfix_transport_maps %}
{{ transport.pattern }} {{ transport.result }}
{% endfor %}

1 change: 1 addition & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down