From 423729cc3cb0644060c97fa02f609ae05c78f3e3 Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Sat, 7 Nov 2020 22:36:05 +0100 Subject: [PATCH] more variables. --- README.adoc | 70 +++++++++++++++++++++++++++++++++++++++++++++++ defaults/main.yml | 19 ++++++++++++- tasks/dovecot.yml | 25 +++++++++-------- tasks/main.yml | 2 +- tasks/postfix.yml | 10 +++---- 5 files changed, 107 insertions(+), 19 deletions(-) diff --git a/README.adoc b/README.adoc index 388d5b0..08d1c6c 100644 --- a/README.adoc +++ b/README.adoc @@ -4,6 +4,37 @@ mail - Secure Postfix & Dovecot Mail is pain. For an easier setup, this role configures a mail-server with secure default settings. +Architecture +============ + +Receiving email:: +postfix listens on port 25. Client should use STARTTLS. +postscreen will protect your mailserver against SPAM at first. +After postscreen allowes the connection, postfix-smtpd will receive the email. +While connection is open and mail will receive, it tries to check SPF and DKIM. +Second the recepient will be checked by connecting to dovecot-lmtpd, +If a check fails, the email will be rejected and client gets 5XX or 4XX. +After accepting email, the client gets an ack and email will be stored. +lmtp will send this email to dovecot-lmtpd, which will call sieve and stores the email. +It should never send errors by mails. Any errors should be handled by rejecting the email. + +Sending email:: +postfix listens on port 587. Client must use STARTTLS, else connection will not accepted. +No postscreen needed. The submission-server (an other smtpd) requires authentication. +The email will not be checked for SPF or DKIM, authentication is enough. +After email is recieved and stored, postfix-smtp will try to send the email(s). +Errors should be send to authenticated user. + +Reading email:: +Dovecot provides IMAP4 on port 143. STARTTLS is required. + +Authentication and users:: +Any user-checks should be done by dovecot, never by postfix. +Special users could exist ist dovecot-users-file. +Regular users will be searched in LDAP. For authentication +a ldap-bind will be used. + + Requirements ------------ @@ -21,6 +52,45 @@ Role Variables TODO +There are three different prefixes: + +mail:: +These are required to set or most users could be interested to set it. +The other prefixes can refer to mail-variables as default-value. + +postfix:: +Postfix-specific + +dovecot:: +Dovecot-specific + +LDAP is required. You need to define `mail_ldap_basedn`. +It will search directly in next-level of `ou=People` of `mail_ldap_basedn` for users. +The users have to be a `simpleSecurityObject` and needs `mail` and `userPassword`. +You can define others. + +mail_server_fqdn:: +Full qualified domain name of your mail server. +It is not possible to choose different for SMTP/Submission/IMAP/Sieve. +But you can use CNAMEs/X509-Alt-names to define different. + +mail_ldap_basedn:: +LDAP-BaseDN. `cn=example,cn=net` + +mail_ldap_uris:: +(default: `ldapi://`) + +mail_ldap_field_user:: +(default: `mail`) + +mail_ldap_field_password:: +(default: `userPassword`) + +postfix_tls_policy:: +tls-policy for given domain. `{smtp.example.net: enforce}` +(default: empty) + + Example Playbook ---------------- diff --git a/defaults/main.yml b/defaults/main.yml index 6c9791f..7975c88 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,22 @@ --- # vim: set et sw=2 ts=2 sts=2: -postfix_tls_policy: [] +mail_server_fqdn: '{{ansible_fqdn}}' +mail_ldap_uris: ldapi:// +mail_ldap_field_user: mail +mail_ldap_field_password: userPassword +mail_ldap_filter: '(&(objectClass=simpleSecurityObject)({{mail_ldap_field_user}}=%u))' +postfix_tls_policy: {} + +dovecot_ldap_uris: "{{mail_ldap_uris}}" +dovecot_ldap_ldaprc_path: /etc/ldap/ldap.conf +dovecot_ldap_base: 'ou=People,{{mail_ldap_basedn}}' +dovecot_ldap_scope: onelevel +dovecot_ldap_filter: '{{mail_ldap_filter}}' +dovecot_ldap_user_filter: '{{dovecot_ldap_filter}}' +dovecot_ldap_user_attrs: '{{mail_ldap_field_user}}=user' +dovecot_ldap_pass_filter: '{{dovecot_ldap_filter}}' +dovecot_ldap_pass_attrs: '{{mail_ldap_field_user}}=user,{{mail_ldap_field_password}}=password' +dovecot_ldap_iterate_attrs: '{{mail_ldap_field_user}}=user' +dovecot_ldap_iterate_filter: '{{dovecot_ldap_filter}}' diff --git a/tasks/dovecot.yml b/tasks/dovecot.yml index 633eca3..ec827d7 100644 --- a/tasks/dovecot.yml +++ b/tasks/dovecot.yml @@ -49,8 +49,8 @@ line: "{{item.key}} = {{item.value}}" with_dict: ssl: required - ssl_key: "