From 35c40c29dde6762e682df699bd8eb5d42ee529ef Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Mon, 2 Dec 2019 17:35:54 +0100 Subject: [PATCH 1/9] Roles enabled in main playbook --- ansible/ispmail.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ansible/ispmail.yml b/ansible/ispmail.yml index aa961eb..f89da8d 100644 --- a/ansible/ispmail.yml +++ b/ansible/ispmail.yml @@ -14,10 +14,10 @@ roles: #- dumpvars - ispmail-packages -# - ispmail-certificate + - ispmail-certificate - ispmail-database -# - ispmail-postfix -# - ispmail-dovecot + - ispmail-postfix + - ispmail-dovecot # - ispmail-webmail - ispmail-webmail-apache-horde - ispmail-tests From b6aad486d2c0ce78413cd26a3171f347cc79244b Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Tue, 3 Dec 2019 10:14:49 +0100 Subject: [PATCH 2/9] Milter rspamd settings added to Postfix --- ansible/roles/ispmail-postfix/tasks/main.yml | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/ansible/roles/ispmail-postfix/tasks/main.yml b/ansible/roles/ispmail-postfix/tasks/main.yml index d60c0af..e9aee6f 100644 --- a/ansible/roles/ispmail-postfix/tasks/main.yml +++ b/ansible/roles/ispmail-postfix/tasks/main.yml @@ -76,25 +76,18 @@ - name: Set TLS encryption key command: postconf smtpd_tls_key_file=/etc/ssl/private/mailserver.pem -# - name: Enabling Spamassassin milter -# command: postconf smtpd_milters=unix:/spamass/spamass.sock - -# - name: Configuring Spamassassin milter -# command: postconf milter_connect_macros="i j {daemon_name} v {if_name} _" - -# - name: Setting spamd options -# copy: src=etc-default-spamassassin dest=/etc/default/spamassassin -# notify: restart spamassassin - -# - name: Adding user spamass-milter to debian-spamd group -# user: name=spamass-milter groups=debian-spamd -# notify: restart spamassassin - -# - name: Enabling spamd at startup -# command: systemctl enable spamassassin - - name: Allow emails up to 40 MB large command: postconf message_size_limit=41943040 - name: Make Postfix listen on all interfaces command: postconf inet_interfaces=all + +- name: Set rspamd milter for smtpd + command: postconf smtpd_milters=inet:127.0.0.1:11332 + +- name: Set rspamd milter for local mails + command: postconf non_smtpd_milters=inet:127.0.0.1:11332 + +- name: Set rspamd milter macros + command: postconf milter_mail_macros="i {mail_addr} {client_addr} {client_name} {auth_authen}" + From 6de64db526993a65fadb11a270ea9242f85761f3 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Tue, 3 Dec 2019 10:15:20 +0100 Subject: [PATCH 3/9] Password variable fixed --- ansible/group_vars/all | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/group_vars/all b/ansible/group_vars/all index 9100a67..d912abc 100644 --- a/ansible/group_vars/all +++ b/ansible/group_vars/all @@ -3,7 +3,7 @@ ispmail_populate_test_data: true # MySQL password for read-only user -ispmail_mysql_mailuser_password: ChangeMe +ispmail_mysql_mailserver_password: ChangeMeServer # MySQL password for administrative root user ispmail_mysql_root_password: ChangeMeRoot From 074ccfe1189bde53756e615a86fff09feb281e34 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Thu, 5 Dec 2019 18:08:10 +0100 Subject: [PATCH 4/9] Antispam features added --- ansible/group_vars/all | 6 +- ansible/ispmail.yml | 3 +- .../roles/ispmail-dovecot/files/15-mailboxes.conf | 80 ++++++++++++++++++++++ ansible/roles/ispmail-dovecot/files/90-sieve.conf | 42 ++++++++---- .../roles/ispmail-dovecot/files/learn-ham.sieve | 3 + .../roles/ispmail-dovecot/files/learn-spam.sieve | 3 + .../ispmail-dovecot/files/rspamd-learn-ham.sh | 2 + .../ispmail-dovecot/files/rspamd-learn-spam.sh | 2 + ansible/roles/ispmail-dovecot/handlers/main.yml | 2 - ansible/roles/ispmail-dovecot/tasks/main.yml | 33 +++++++++ ansible/roles/ispmail-packages/tasks/main.yml | 1 + .../ispmail-rspamd/files/classifier-bayes.conf | 0 .../roles/ispmail-rspamd/files/milter_headers.conf | 1 + ansible/roles/ispmail-rspamd/files/redis.conf | 1 + ansible/roles/ispmail-rspamd/files/statistic.conf | 3 + ansible/roles/ispmail-rspamd/handlers/site.yml | 5 ++ ansible/roles/ispmail-rspamd/tasks/main.yml | 41 +++++++++++ .../templates/worker-controller.conf.j2 | 1 + .../tasks/main.yml | 22 +++--- .../templates/vhosts/https.j2 | 7 ++ 20 files changed, 232 insertions(+), 26 deletions(-) create mode 100644 ansible/roles/ispmail-dovecot/files/15-mailboxes.conf create mode 100644 ansible/roles/ispmail-dovecot/files/learn-ham.sieve create mode 100644 ansible/roles/ispmail-dovecot/files/learn-spam.sieve create mode 100644 ansible/roles/ispmail-dovecot/files/rspamd-learn-ham.sh create mode 100644 ansible/roles/ispmail-dovecot/files/rspamd-learn-spam.sh create mode 100644 ansible/roles/ispmail-rspamd/files/classifier-bayes.conf create mode 100644 ansible/roles/ispmail-rspamd/files/milter_headers.conf create mode 100644 ansible/roles/ispmail-rspamd/files/redis.conf create mode 100644 ansible/roles/ispmail-rspamd/files/statistic.conf create mode 100644 ansible/roles/ispmail-rspamd/handlers/site.yml create mode 100644 ansible/roles/ispmail-rspamd/tasks/main.yml create mode 100644 ansible/roles/ispmail-rspamd/templates/worker-controller.conf.j2 diff --git a/ansible/group_vars/all b/ansible/group_vars/all index e5e2f95..cdee4aa 100644 --- a/ansible/group_vars/all +++ b/ansible/group_vars/all @@ -34,6 +34,10 @@ ispmail_postmaster_address: postmaster@example.org # that points to your server. ispmail_webmail_hostname: 10.0.0.100 +# Password for rspamd web interface authentication at +# https://…/rspamd +ispmail_rspamd_web_password: ChangeMeRspamd + # Information for self-signed certificate ispmail_certificate_country: DE ispmail_certificate_state: Schleswig-Holstein @@ -44,5 +48,3 @@ ispmail_certificate_domains: - example.org ispmail_certificate_email: postmaster@example.org ispmail_certificate_days_valid: 3650 - -# TODO: Let's Encrypt email address diff --git a/ansible/ispmail.yml b/ansible/ispmail.yml index de3cd86..f307e2f 100644 --- a/ansible/ispmail.yml +++ b/ansible/ispmail.yml @@ -25,6 +25,7 @@ tags: dovecot - role: ispmail-webmail-apache-roundcube tags: roundcube + - role: ispmail-rspamd + tags: rspamd # - ispmail-webmail-apache-horde #- ispmail-tests - diff --git a/ansible/roles/ispmail-dovecot/files/15-mailboxes.conf b/ansible/roles/ispmail-dovecot/files/15-mailboxes.conf new file mode 100644 index 0000000..2f03a98 --- /dev/null +++ b/ansible/roles/ispmail-dovecot/files/15-mailboxes.conf @@ -0,0 +1,80 @@ +## +## Mailbox definitions +## + +# Each mailbox is specified in a separate mailbox section. The section name +# specifies the mailbox name. If it has spaces, you can put the name +# "in quotes". These sections can contain the following mailbox settings: +# +# auto: +# Indicates whether the mailbox with this name is automatically created +# implicitly when it is first accessed. The user can also be automatically +# subscribed to the mailbox after creation. The following values are +# defined for this setting: +# +# no - Never created automatically. +# create - Automatically created, but no automatic subscription. +# subscribe - Automatically created and subscribed. +# +# special_use: +# A space-separated list of SPECIAL-USE flags (RFC 6154) to use for the +# mailbox. There are no validity checks, so you could specify anything +# you want in here, but it's not a good idea to use flags other than the +# standard ones specified in the RFC: +# +# \All - This (virtual) mailbox presents all messages in the +# user's message store. +# \Archive - This mailbox is used to archive messages. +# \Drafts - This mailbox is used to hold draft messages. +# \Flagged - This (virtual) mailbox presents all messages in the +# user's message store marked with the IMAP \Flagged flag. +# \Junk - This mailbox is where messages deemed to be junk mail +# are held. +# \Sent - This mailbox is used to hold copies of messages that +# have been sent. +# \Trash - This mailbox is used to hold messages that have been +# deleted. +# +# comment: +# Defines a default comment or note associated with the mailbox. This +# value is accessible through the IMAP METADATA mailbox entries +# "/shared/comment" and "/private/comment". Users with sufficient +# privileges can override the default value for entries with a custom +# value. + +# NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf. +namespace inbox { + # These mailboxes are widely used and could perhaps be created automatically: + mailbox Drafts { + special_use = \Drafts + } + mailbox Junk { + special_use = \Junk + autoexpunge = 30d + } + mailbox Trash { + special_use = \Trash + autoexpunge = 30d + } + + # For \Sent mailboxes there are two widely used names. We'll mark both of + # them as \Sent. User typically deletes one of them if duplicates are created. + mailbox Sent { + special_use = \Sent + } + mailbox "Sent Messages" { + special_use = \Sent + } + + # If you have a virtual "All messages" mailbox: + #mailbox virtual/All { + # special_use = \All + # comment = All my messages + #} + + # If you have a virtual "Flagged" mailbox: + #mailbox virtual/Flagged { + # special_use = \Flagged + # comment = All my flagged messages + #} +} diff --git a/ansible/roles/ispmail-dovecot/files/90-sieve.conf b/ansible/roles/ispmail-dovecot/files/90-sieve.conf index 6a2be9e..c37129e 100644 --- a/ansible/roles/ispmail-dovecot/files/90-sieve.conf +++ b/ansible/roles/ispmail-dovecot/files/90-sieve.conf @@ -16,7 +16,7 @@ # # location = [:]path[;