diff --git a/Dockerfile b/Dockerfile index 78650c6..fc89ab2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN rm -rf $HOME/.cache # ansible RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev && \ apt-get clean -RUN pip install ansible==2.9.14 +RUN pip install ansible==2.9.15 RUN rm -rf $HOME/.cache # provision diff --git a/README.md b/README.md index 8f95bc6..9f27db7 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ None * `postfix_install` [default: `[postfix, mailutils, libsasl2-2, sasl2-bin, libsasl2-modules]`]: Packages to install * `postfix_hostname` [default: `{{ ansible_fqdn }}`]: Host name, used for `myhostname` and in `mydestination` * `postfix_mailname` [default: `{{ ansible_fqdn }}`]: Mail name (in `/etc/mailname`), used for `myorigin` + + * `postfix_compatibility_level` [optional]: With backwards compatibility turned on (the compatibility_level value is less than the Postfix built-in value), Postfix looks for settings that are left at their implicit default value, and logs a message when a backwards-compatible default setting is required (e.g. `2`, `Postfix >= 3.0`) + + * `postfix_default_database_type` [default: `hash`]: The default database type for use in `newaliases`, `postalias` and `postmap` commands * `postfix_aliases` [default: `[]`]: Aliases to ensure present in `/etc/aliases` * `postfix_virtual_aliases` [default: `[]`]: Virtual aliases to ensure present in `/etc/postfix/virtual` * `postfix_sender_canonical_maps` [default: `[]`]: Sender address rewriting in `/etc/postfix/sender_canonical_maps` ([see](http://www.postfix.org/postconf.5.html#transport_maps)) @@ -24,36 +28,44 @@ None * `postfix_transport_maps_database_type` [default: `"{{ postfix_default_database_type }}"`]: The database type for use in `postfix_transport_maps` * `postfix_sender_dependent_relayhost_maps` [default: `[]`]: Transport mapping based on sender address `/etc/postfix/sender_dependent_relayhost_maps` ([see](http://www.postfix.org/postconf.5.html#recipient_canonical_maps)) * `postfix_header_checks` [default: `[]`]: Lookup tables for content inspection of primary non-MIME message headers `/etc/postfix/header_checks` ([see](http://www.postfix.org/postconf.5.html#header_checks)) - * `postfix_generic:` [default: `[]`]: Generic table address mapping in `/etc/postfix/generic` ([see](http://www.postfix.org/generic.5.html)) + * `postfix_header_checks_database_type` [default: `regexp`]: The database type for use in `header_checks` + * `postfix_generic` [default: `[]`]: Generic table address mapping in `/etc/postfix/generic` ([see](http://www.postfix.org/generic.5.html)) + * `postfix_mydestination` [default: `["{{ postfix_hostname }}", 'localdomain', 'localhost', 'localhost.localdomain']`]: Specifies what domains this machine will deliver locally, instead of forwarding to another machine * `postfix_mynetworks` [default: `['127.0.0.0/8', '[::ffff:127.0.0.0]/104', '[::1]/128']`]: The list of "trusted" remote SMTP clients that have more privileges than "strangers" * `postfix_inet_interfaces` [default: `all`]: Network interfaces to bind ([see](http://www.postfix.org/postconf.5.html#inet_interfaces)) * `postfix_inet_protocols` [default: `all`]: The Internet protocols Postfix will attempt to use when making or accepting connections ([see](http://www.postfix.org/postconf.5.html#inet_protocols)) - * `postfix_sasl_auth_enable` [default: `true`]: Enable SASL authentication in the SMTP client + * `postfix_relayhost` [default: `''` (no relay host)]: Hostname to relay all email to * `postfix_relayhost_mxlookup` [default: `false` (not using mx lookup)]: Lookup for MX record instead of A record for relayhost * `postfix_relayhost_port` [default: 587]: Relay port (on `postfix_relayhost`, if set) + * `postfix_relaytls` [default: `false`]: Use TLS when sending with a relay host + * `postfix_smtpd_client_restrictions` [optional]: List of client restrictions ([see](http://www.postfix.org/postconf.5.html#smtpd_client_restrictions)) * `postfix_smtpd_helo_restrictions` [optional]: List of helo restrictions ([see](http://www.postfix.org/postconf.5.html#smtpd_helo_restrictions)) * `postfix_smtpd_sender_restrictions` [optional]: List of sender restrictions ([see](http://www.postfix.org/postconf.5.html#smtpd_sender_restrictions)) * `postfix_smtpd_recipient_restrictions` [optional]: List of recipient restrictions ([see](http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions)) * `postfix_smtpd_relay_restrictions` [optional]: List of access restrictions for mail relay control ([see](http://www.postfix.org/postconf.5.html#smtpd_relay_restrictions)) * `postfix_smtpd_data_restrictions` [optional]: List of data restrictions ([see](http://www.postfix.org/postconf.5.html#smtpd_data_restrictions)) + + * `postfix_sasl_auth_enable` [default: `true`]: Enable SASL authentication in the SMTP client + * `postfix_sasl_user` [default: `postmaster@{{ ansible_domain }}`]: SASL relay username + * `postfix_sasl_password` [default: `k8+haga4@#pR`]: SASL relay password **Make sure to change!** * `postfix_sasl_security_options` [default: `noanonymous`]: SMTP client SASL security options * `postfix_sasl_tls_security_option` [default: `noanonymous`]: SMTP client SASL TLS security options * `postfix_sasl_mechanism_filter` [default: `''`]: SMTP client SASL authentication mechanism filter ([see](http://www.postfix.org/postconf.5.html#smtp_sasl_mechanism_filter)) - * `postfix_relaytls` [default: `false`]: Use TLS when sending with a relay host + + * `postfix_smtp_tls_security_level` [default: `encrypt`]: The default SMTP TLS security level for the Postfix SMTP client ([see](http://www.postfix.org/postconf.5.html#smtp_tls_security_level)) + * `postfix_smtp_tls_note_starttls_offer` [default: `true`]: Log the hostname of a remote SMTP server that offers STARTTLS, when TLS is not already enabled for that server ([see](http://www.postfix.org/postconf.5.html#smtp_tls_note_starttls_offer)) * `postfix_smtp_tls_cafile` [optional]: A file containing CA certificates of root CAs trusted to sign either remote SMTP server certificates or intermediate CA certificates (e.g. `/etc/ssl/certs/ca-certificates.crt`) - * `postfix_sasl_user` [default: `postmaster@{{ ansible_domain }}`]: SASL relay username - * `postfix_sasl_password` [default: `k8+haga4@#pR`]: SASL relay password **Make sure to change!** + * `postfix_smtpd_banner` [default: `$myhostname ESMTP $mail_name (Ubuntu)`]: Greeting banner **You MUST specify $myhostname at the start of the text. This is required by the SMTP protocol.** - * `postfix_compatibility_level` [optional]: With backwards compatibility turned on (the compatibility_level value is less than the Postfix built-in value), Postfix looks for settings that are left at their implicit default value, and logs a message when a backwards-compatible default setting is required (e.g. `2`, `Postfix >= 3.0`) * `postfix_disable_vrfy_command` [default: `false`]: Disable the `SMTP VRFY` command. This stops some techniques used to harvest email addresses * `postfix_message_size_limit` [default: `10240000`]: The maximal size in bytes of a message, including envelope information - * `postfix_header_checks_database_type` [default: `regexp`]: The database type for use in `header_checks` - * `postfix_default_database_type` [default: `hash`]: The default database type for use in `newaliases`, `postalias` and `postmap` commands + * `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) ## Dependencies diff --git a/defaults/main.yml b/defaults/main.yml index 8038835..7c34d8c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,8 +6,11 @@ postfix_install: - libsasl2-2 - sasl2-bin - libsasl2-modules + postfix_hostname: "{{ ansible_fqdn }}" postfix_mailname: "{{ ansible_fqdn }}" + +postfix_default_database_type: hash postfix_aliases: [] postfix_virtual_aliases: [] postfix_sender_canonical_maps: [] @@ -19,16 +22,22 @@ postfix_transport_maps_database_type: "{{ postfix_default_database_type }}" postfix_sender_dependent_relayhost_maps: [] postfix_header_checks: [] postfix_generic: [] + postfix_relayhost: '' postfix_relayhost_mxlookup: false postfix_relayhost_port: 587 postfix_relaytls: false + postfix_sasl_auth_enable: true postfix_sasl_user: "postmaster@{{ ansible_domain }}" postfix_sasl_password: 'k8+haga4@#pR' postfix_sasl_security_options: noanonymous postfix_sasl_tls_security_options: noanonymous postfix_sasl_mechanism_filter: '' + +postfix_smtp_tls_security_level: encrypt +postfix_smtp_tls_note_starttls_offer: true + postfix_inet_interfaces: all postfix_inet_protocols: all postfix_mydestination: @@ -40,11 +49,12 @@ postfix_mynetworks: - 127.0.0.0/8 - '[::ffff:127.0.0.0]/104' - '[::1]/128' + postfix_smtpd_banner: '$myhostname ESMTP $mail_name (Ubuntu)' postfix_disable_vrfy_command: false postfix_message_size_limit: 10240000 -postfix_header_checks_database_type: regexp -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: [] diff --git a/templates/etc/postfix/main.cf.j2 b/templates/etc/postfix/main.cf.j2 index c669210..3fc24dc 100644 --- a/templates/etc/postfix/main.cf.j2 +++ b/templates/etc/postfix/main.cf.j2 @@ -23,8 +23,8 @@ compatibility_level = {{ postfix_compatibility_level }} {% endif %} # TLS parameters -smtpd_tls_cert_file={{ postfix_smtpd_tls_cert_file }} -smtpd_tls_key_file={{ postfix_smtpd_tls_key_file }} +smtpd_tls_cert_file = {{ postfix_smtpd_tls_cert_file }} +smtpd_tls_key_file = {{ postfix_smtpd_tls_key_file }} smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache @@ -80,15 +80,15 @@ relayhost = [{{ postfix_relayhost }}]:{{ postfix_relayhost_port }} {% endif %} {% if postfix_sasl_auth_enable %} smtp_sasl_auth_enable = {{ postfix_sasl_auth_enable | bool | ternary('yes', 'no') }} -smtp_sasl_password_maps = {{ postfix_default_database_type }}:/etc/postfix/sasl_passwd +smtp_sasl_password_maps = {{ postfix_default_database_type }}:{{ postfix_sasl_passwd_file }} smtp_sasl_security_options = {{ postfix_sasl_security_options }} smtp_sasl_tls_security_options = {{ postfix_sasl_tls_security_options }} smtp_sasl_mechanism_filter = {{ postfix_sasl_mechanism_filter }} {% endif %} {% if postfix_relaytls %} -smtp_use_tls = yes -smtp_tls_security_level = encrypt -smtp_tls_note_starttls_offer = yes +smtp_use_tls = {{ postfix_relaytls | bool | ternary('yes', 'no') }} +smtp_tls_security_level = {{ postfix_smtp_tls_security_level }} +smtp_tls_note_starttls_offer = {{ postfix_smtp_tls_note_starttls_offer | bool | ternary('yes', 'no') }} {% if postfix_smtp_tls_cafile is defined %} smtp_tls_CAfile = {{ postfix_smtp_tls_cafile }} {% endif %}