summaryrefslogtreecommitdiffstats
path: root/roles/common/templates/etc/postfix
diff options
context:
space:
mode:
Diffstat (limited to 'roles/common/templates/etc/postfix')
-rw-r--r--roles/common/templates/etc/postfix/main.cf.j252
-rw-r--r--roles/common/templates/etc/postfix/master.cf.j2114
-rw-r--r--roles/common/templates/etc/postfix/tls_policy.j225
3 files changed, 129 insertions, 62 deletions
diff --git a/roles/common/templates/etc/postfix/main.cf.j2 b/roles/common/templates/etc/postfix/main.cf.j2
index 1b0bc4a..5ac7920 100644
--- a/roles/common/templates/etc/postfix/main.cf.j2
+++ b/roles/common/templates/etc/postfix/main.cf.j2
@@ -1,70 +1,48 @@
########################################################################
# Nullmailer configuration
#
# {{ ansible_managed }}
# Do NOT edit this file directly!
-smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
-biff = no
-readme_directory = no
-mail_owner = postfix
+smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
+biff = no
+readme_directory = no
+compatibility_level = 2
+smtputf8_enable = no
myorigin = /etc/mailname
myhostname = {{ ansible_fqdn }}
mydomain = {{ ansible_domain }}
append_dot_mydomain = no
# This server is for internal use only
mynetworks_style = host
inet_interfaces = loopback-only
# No local delivery
mydestination =
local_transport = error:5.1.1 Mailbox unavailable
alias_maps =
local_recipient_maps =
# All aliases are virtual
-default_database_type = cdb
-virtual_alias_maps = cdb:/etc/aliases
+default_database_type = lmdb
+virtual_alias_maps = lmdb:/etc/aliases
alias_database = $virtual_alias_maps
# Forward everything to our internal outgoing proxy
-{% if 'out' in group_names %}
-relayhost = [127.0.0.1]:{{ postfix_instance.out.port }}
-{% else %}
-relayhost = [outgoing.fripost.org]:{{ postfix_instance.out.port }}
-{% endif %}
+relayhost = [{{ postfix_instance.out.addr | ansible.utils.ipaddr }}]:{{ postfix_instance.out.port }}
relay_domains =
-{% if 'out' in group_names %}
-smtp_tls_security_level = none
-smtp_bind_address = 127.0.0.1
-{% else %}
-smtp_tls_security_level = encrypt
-smtp_tls_cert_file = $config_directory/ssl/{{ ansible_fqdn }}.pem
-smtp_tls_key_file = $config_directory/ssl/{{ ansible_fqdn }}.key
-smtp_tls_session_cache_database = btree:$data_directory/smtp_tls_session_cache
-smtp_tls_policy_maps = cdb:$config_directory/tls_policy
-smtp_tls_fingerprint_digest = sha256
-{% endif %}
-smtpd_tls_security_level = none
-
-# Turn off all TCP/IP listener ports except that dedicated to
-# samhain(8), which sadly cannot use pickup through the sendmail binary.
-master_service_disable = !127.0.0.1:16132.inet inet
+smtp_tls_security_level = none
+smtpd_tls_security_level = none
-{% set multi_instance = False %}
-{%- for g in postfix_instance.keys() | sort -%}
- {%- if g in group_names -%}
- {%- if not multi_instance -%}
- {%- set multi_instance = True -%}
-## Other postfix instances
+{% set instances = postfix_instance.keys() | intersect(group_names) | list %}
+{%- if instances | length > 0 -%}
+# Other postfix instances
multi_instance_wrapper = $command_directory/postmulti -p --
multi_instance_enable = yes
-multi_instance_directories =
- {%- endif %} /etc/postfix-{{ postfix_instance[g].name }}
- {%- endif %}
-{% endfor %}
+multi_instance_directories ={% for i in instances | sort %} /etc/postfix-{{ postfix_instance[i].name }}{% endfor %}
+{% endif %}
# vim: set filetype=pfmain :
diff --git a/roles/common/templates/etc/postfix/master.cf.j2 b/roles/common/templates/etc/postfix/master.cf.j2
new file mode 100644
index 0000000..3954085
--- /dev/null
+++ b/roles/common/templates/etc/postfix/master.cf.j2
@@ -0,0 +1,114 @@
+########################################################################
+# Postfix master process configuration file. For details on the format
+# of the file, see the master(5) manual page (command: "man 5 master").
+#
+# {{ ansible_managed }}
+# Do NOT edit this file directly!
+#
+# ==========================================================================
+# service type private unpriv chroot wakeup maxproc command + args
+# (yes) (yes) (yes) (never) (100)
+# ==========================================================================
+
+{% if inst is not defined %}
+[127.0.0.1]:16132 inet n - y - - smtpd
+{% elif inst == 'MX' %}
+smtpd pass - - y - - smtpd
+smtp inet n - y - 1 postscreen
+tlsproxy unix - - y - 0 tlsproxy
+dnsblog unix - - y - 0 dnsblog
+{% elif inst == 'MSA' %}
+submission inet n - y - - smtpd
+submissions inet n - y - - smtpd
+ -o smtpd_tls_wrappermode=yes
+{% if groups.webmail | difference([inventory_hostname]) | length > 0 %}
+[{{ postfix_instance.MSA.addr }}]:{{ postfix_instance.MSA.port }} inet n - y - - smtpd
+ -o broken_sasl_auth_clients=no
+ -o smtpd_tls_security_level=none
+ -o smtpd_sasl_security_options=noanonymous
+ -o smtpd_sasl_exceptions_networks=
+ -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128{{ ipsec_subnet is defined | ternary(','+ipsec_subnet, '') }}
+ -o smtpd_peername_lookup=no
+{% endif %}
+{% elif inst in ['IMAP', 'out', 'lists'] %}
+[{{ postfix_instance[inst].addr }}]:{{ postfix_instance[inst].port }} inet n - y - - smtpd
+ -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128{{ ipsec_subnet is defined | ternary(','+ipsec_subnet, '') }}
+ -o smtpd_peername_lookup=no
+{% endif %}
+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
+# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
+{% if inst is defined and inst == 'MSA' %}
+smtp_verify unix - - y - - smtp
+ -o smtp_helo_name=noreply.$mydomain
+ -o smtp_tls_security_level=may
+ -o smtp_tls_ciphers=medium
+ -o smtp_tls_protocols=!SSLv2,!SSLv3
+ -o smtp_tls_note_starttls_offer=yes
+ -o smtp_tls_session_cache_database=lmdb:$data_directory/smtp_tls_session_cache
+ -o smtp_tls_fingerprint_digest=sha256
+ -o smtp_tls_policy_maps=lmdb:$config_directory/smtp_tls_policy
+{% endif %}
+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
+{% if inst is defined and inst == 'MSA' %}
+policyd-spf unix - n n - 0 spawn
+ user=policyd-spf argv=/usr/bin/policyd-spf
+{% endif %}
+{% if inst is defined and inst == 'MX' %}
+reserved-alias unix - n n - - pipe
+ flags=Rhu user=nobody argv=/usr/local/bin/reserved-alias.pl ${sender} ${original_recipient} @fripost.org
+{% endif %}
+{% if inst is defined and inst == 'lists' %}
+sympa unix - n n - - pipe
+ flags=Rhu user=sympa argv=/usr/local/bin/sympa-queue ${user}
+{% endif %}
+
+{% if inst is defined and inst == 'out' %}
+# Client part (lmtp) - amavis
+amavisfeed unix - - y - 5 lmtp
+ -o lmtp_destination_recipient_limit=1000
+ -o lmtp_send_xforward_command=yes
+ -o lmtp_data_done_timeout=1200s
+ -o disable_dns_lookups=yes
+
+# Server part (smtpd) - amavis
+[127.0.0.1]:10025 inet n - y - - smtpd
+ -o content_filter=
+ -o smtpd_delay_reject=no
+ -o smtpd_client_restrictions=permit_mynetworks,reject
+ -o smtpd_helo_restrictions=
+ -o smtpd_sender_restrictions=
+ -o smtpd_relay_restrictions=permit_mynetworks,reject
+ -o smtpd_data_restrictions=reject_unauth_pipelining
+ -o smtpd_end_of_data_restrictions=
+ -o smtpd_restriction_classes=
+ -o mynetworks_style=host
+ -o smtpd_error_sleep_time=0
+ -o smtpd_soft_error_limit=1001
+ -o smtpd_hard_error_limit=1000
+ -o smtpd_client_connection_count_limit=0
+ -o smtpd_client_connection_rate_limit=0
+ -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
+ -o local_header_rewrite_clients=
+ -o smtpd_authorized_xforward_hosts=127.0.0.0/8
+{% endif %}
diff --git a/roles/common/templates/etc/postfix/tls_policy.j2 b/roles/common/templates/etc/postfix/tls_policy.j2
deleted file mode 100644
index 5ff7d26..0000000
--- a/roles/common/templates/etc/postfix/tls_policy.j2
+++ /dev/null
@@ -1,25 +0,0 @@
-# {{ ansible_managed }}
-# /!\ WARNING: smtp_tls_fingerprint_digest MUST be sha256!
-
-{% if 'out' not in group_names %}
-[outgoing.fripost.org]:{{ postfix_instance.out.port }} fingerprint ciphers=high protocols=TLSv1.2
-{% for h in groups.out | sort %}
- match={{ lookup('pipe', 'openssl x509 -in certs/postfix/'+h+'.pem -noout -fingerprint -sha256 | cut -d= -f2') }}
-{% endfor %}
-{% endif %}
-
-{% if 'MX' in group_names %}
-{% if 'IMAP' not in group_names %}
-[mda.fripost.org]:{{ postfix_instance.IMAP.port }} fingerprint ciphers=high protocols=TLSv1.2
-{% for h in groups.IMAP | sort %}
- match={{ lookup('pipe', 'openssl x509 -in certs/postfix/'+h+'.pem -noout -fingerprint -sha256 | cut -d= -f2') }}
-{% endfor %}
-{% endif %}
-
-{% if 'lists' not in group_names %}
-[lists.fripost.org]:{{ postfix_instance.lists.port }} fingerprint ciphers=high protocols=TLSv1.2
-{% for h in groups.lists | sort %}
- match={{ lookup('pipe', 'openssl x509 -in certs/postfix/'+h+'.pem -noout -fingerprint -sha256 | cut -d= -f2') }}
-{% endfor %}
-{% endif %}
-{% endif %}