improve dovecot

This commit is contained in:
genofire 2020-07-22 23:20:10 +02:00
parent 605d353b7c
commit 5b761c2004
17 changed files with 191 additions and 24 deletions

View File

@ -1,18 +1,22 @@
--- ---
mailserver_mail_domain: "sum7.eu"
mailserver_mx_domain: "{{ inventory_hostname }}"
mailserver_cert_domains: "{{ mailserver_mx_domain }} mail.{{ mailserver_mail_domain }}"
mailserver_db_type: "pgsql" mailserver_db_type: "pgsql"
mailserver_db_host: "localhost" mailserver_db_host: "localhost"
mailserver_db_name: "mailserver" mailserver_db_name: "mailserver"
mailserver_db_user: "mailserver" mailserver_db_user: "mailserver"
mailserver_db_password: "{{ lookup('password', 'credentials/' + inventory_hostname + '/mailserver/db_password length=15') }}" mailserver_db_password: "{{ lookup('password', 'credentials/' + inventory_hostname + '/mailserver/db_password length=15') }}"
#mailserver_postfixadmin_setup_password: "" # after postfixadmin-setup #mailserver_postfixadmin_setup_password: "" # after postfixadmin-setup
mailserver_postfixadmin_domain: "" mailserver_postfixadmin_domain: ""
mailserver_postfixadmin_mail_domain: "sum7.eu" mailserver_postfixadmin_mail_admin: "admin@{{ mailserver_mail_domain }}"
mailserver_postfixadmin_mail_admin: "admin@{{ mailserver_postfixadmin_mail_domain }}"
mailserver_postfixadmin_setup: "" mailserver_postfixadmin_setup: ""
mailserver_postfixadmin_default_aliases: mailserver_postfixadmin_default_aliases:
abuse: "abuse@{{ mailserver_postfixadmin_mail_domain }}" abuse: "abuse@{{ mailserver_mail_domain }}"
hostmaster: "hostmaster@{{ mailserver_postfixadmin_mail_domain }}" hostmaster: "hostmaster@{{ mailserver_mail_domain }}"
postmaster: "postmaster@{{ mailserver_postfixadmin_mail_domain }}" postmaster: "postmaster@{{ mailserver_mail_domain }}"
webmaster: "webmaster@{{ mailserver_postfixadmin_mail_domain }}" webmaster: "webmaster@{{ mailserver_mail_domain }}"
mailserver_rspamd_enabled: true

View File

@ -3,3 +3,8 @@
systemd: systemd:
name: nginx name: nginx
state: reloaded state: reloaded
- name: restart dovecot
systemd:
name: dovecot
state: restarted

View File

@ -1,4 +1,4 @@
- name: Install PostgreSQL - name: DB - Install PostgreSQL
package: package:
state: latest state: latest
name: name:
@ -7,12 +7,12 @@
- postgresql-old-upgrade - postgresql-old-upgrade
- postgis - postgis
- name: Ensure a locale exists - name: DB - Ensure a locale exists
locale_gen: locale_gen:
name: en_US.UTF-8 name: en_US.UTF-8
state: present state: present
- name: init db - name: DB - Init
become: yes become: yes
become_user: postgres become_user: postgres
become_method: su become_method: su
@ -20,19 +20,19 @@
args: args:
creates: /var/lib/postgres/data/postgresql.conf creates: /var/lib/postgres/data/postgresql.conf
- name: start db - name: DB - starting
systemd: systemd:
name: postgresql name: postgresql
enabled: yes enabled: yes
state: started state: started
- name: create db user - name: DB - create user
postgresql_user: postgresql_user:
login_host: "{{ mailserver_db_host }}" login_host: "{{ mailserver_db_host }}"
name: "{{ mailserver_db_user }}" name: "{{ mailserver_db_user }}"
password: "{{ mailserver_db_password }}" password: "{{ mailserver_db_password }}"
- name: create db - name: DB - create database
postgresql_db: postgresql_db:
login_host: "{{ mailserver_db_host }}" login_host: "{{ mailserver_db_host }}"
name: "{{ mailserver_db_name }}" name: "{{ mailserver_db_name }}"

View File

@ -1,11 +1,18 @@
- name: Install dovecot - name: dovecot - install
package: package:
state: latest state: latest
name: name:
- dovecot - dovecot
- pigeonhole - pigeonhole
- name: dovecot create config folder - name: dovecot - generate DH
notify: restart dovecot
openssl_dhparam:
path: /etc/dovecot/dh.pem
size: 4096
- name: dovecot - create config folder
notify: restart dovecot
file: file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
@ -14,7 +21,8 @@
- /etc/dovecot - /etc/dovecot
- /etc/dovecot/conf.d - /etc/dovecot/conf.d
- name: take default dovecot config - name: dovecot - take default config
notify: restart dovecot
copy: copy:
remote_src: yes remote_src: yes
src: "/usr/share/doc/dovecot/example-config/{{ item }}" src: "/usr/share/doc/dovecot/example-config/{{ item }}"
@ -23,7 +31,8 @@
- conf.d/auth-sql.conf.ext - conf.d/auth-sql.conf.ext
- name: dovecot config - name: dovecot - config
notify: restart dovecot
template: template:
src: "dovecot/{{ item }}" src: "dovecot/{{ item }}"
dest: "/etc/dovecot/{{ item }}" dest: "/etc/dovecot/{{ item }}"
@ -31,4 +40,19 @@
- dovecot-sql.conf.ext - dovecot-sql.conf.ext
- dovecot.conf - dovecot.conf
- conf.d/10-auth.conf - conf.d/10-auth.conf
- conf.d/10-mail.conf
- conf.d/10-master.conf
- conf.d/10-ssl.conf
- conf.d/15-mailboxes.conf
- conf.d/20-imap.conf
- conf.d/20-lmtp.conf
- conf.d/20-managesieve.conf
- conf.d/90-quota.conf
- conf.d/90-sieve.conf
- conf.d/91-stats.conf
- name: dovecot - start and enable on boot
systemd:
name: dovecot
enabled: yes
state: restarted

View File

@ -16,6 +16,12 @@
shell: /usr/bin/nologin shell: /usr/bin/nologin
home: /srv/mail home: /srv/mail
- name: get mx cert
notify: dehydrated
lineinfile:
path: /etc/dehydrated/domains.txt
line: "{{ mailserver_cert_domains }}"
- name: Run userdatabase - name: Run userdatabase
import_tasks: db.yml import_tasks: db.yml
@ -27,6 +33,7 @@
- name: Run rspamd - name: Run rspamd
import_tasks: rspamd.yml import_tasks: rspamd.yml
when: mailserver_rspamd_enabled
- name: Run mailman - name: Run mailman
import_tasks: mailman.yml import_tasks: mailman.yml

View File

@ -1,28 +1,28 @@
- name: package - name: postfixadmin - install
package: package:
name: name:
- postfixadmin - postfixadmin
- name: nginx local - name: postfixadmin - nginx local
notify: reload nginx notify: reload nginx
when: mailserver_postfixadmin_domain == "" when: mailserver_postfixadmin_domain == ""
template: template:
src: postfixadmin-local.nginx src: postfixadmin-local.nginx
dest: /etc/nginx/local.d/postfixadmin.act dest: /etc/nginx/local.d/postfixadmin.act
- name: nginx domain - name: postfixadmin - nginx domain
notify: reload nginx notify: reload nginx
when: mailserver_postfixadmin_domain != "" when: mailserver_postfixadmin_domain != ""
template: template:
src: postfixadmin-domain.nginx src: postfixadmin-domain.nginx
dest: /etc/nginx/sites.d/postfixadmin.act dest: /etc/nginx/sites.d/postfixadmin.act
- name: config postfixadmin - name: postfixadmin - config
template: template:
src: postfixadmin.local.php src: postfixadmin.local.php
dest: /etc/webapps/postfixadmin/config.local.php dest: /etc/webapps/postfixadmin/config.local.php
- name: allow access php to postfixadmin.conf - name: postfixadmin - fix config access
file: file:
path: "/etc/webapps/postfixadmin/{{ item }}" path: "/etc/webapps/postfixadmin/{{ item }}"
owner: http owner: http
@ -31,7 +31,7 @@
- config.inc.php - config.inc.php
- config.local.php - config.local.php
- name: config caching - name: postfixadmin - fix caching access
file: file:
path: "{{ item }}" path: "{{ item }}"
owner: http owner: http

View File

@ -0,0 +1,8 @@
#mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_location = maildir:~/Maildir
namespace inbox {
inbox = yes
}
mail_uid = 5000
mail_gid = 5000
mail_plugins = quota old_stats

View File

@ -0,0 +1,45 @@
service imap-login {
inet_listener imap {
}
inet_listener imaps {
}
}
service pop3-login {
inet_listener pop3 {
}
inet_listener pop3s {
}
}
service lmtp {
unix_listener lmtp {
}
unix_listener /var/spool/postfix/private/dovecot-lmtp {
mode = 0600
user = postfix
group = postfix
}
}
service imap {
executable = imap
}
service pop3 {
executable = pop3
}
service auth {
unix_listener auth-userdb {
user = vmail
}
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
}
service auth-worker {
}
service dict {
unix_listener dict {
mode = 0600
user = vmail
}
}

View File

@ -0,0 +1,6 @@
ssl = required
ssl_cert = </etc/dehydrated/certs/{{ mailserver_cert_domains.split(' ')[0] }}/fullchain.pem
ssl_key = </etc/dehydrated/certs/{{ mailserver_cert_domains.split(' ')[0] }}/privkey.pem
ssl_dh = </etc/dovecot/dh.pem
ssl_min_protocol = TLSv1.1
ssl_cipher_list = EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4

View File

@ -0,0 +1,18 @@
namespace inbox {
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox Junk {
auto = subscribe
special_use = \Junk
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
}

View File

@ -0,0 +1,4 @@
protocol imap {
mail_plugins = $mail_plugins imap_quota imap_sieve imap_old_stats
imap_idle_notify_interval = 29 mins
}

View File

@ -0,0 +1,4 @@
protocol lmtp {
postmaster_address = postmaster@{{ mailserver_mail_domain }}
mail_plugins = $mail_plugins sieve
}

View File

@ -0,0 +1,6 @@
service managesieve-login {
}
service managesieve {
}
protocol sieve {
}

View File

@ -0,0 +1,3 @@
plugin {
quota = dict:User quota::proxy::quota
}

View File

@ -0,0 +1,17 @@
plugin {
sieve = ~/.dovecot.sieve
sieve_dir = ~/sieve
sieve_before = /srv/mail/sieve/spam.sieve
sieve_global_extensions = +vnd.dovecot.pipe
sieve_plugins = sieve_imapsieve sieve_extprograms
sieve_pipe_bin_dir = /usr/bin
{% if mailserver_rspamd_enabled %}
imapsieve_mailbox1_name = Junk
imapsieve_mailbox1_causes = COPY
imapsieve_mailbox1_before = file:/srv/mail/sieve/learn-spam.sieve
imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Junk
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before = file:/srv/mail/sieve/learn-ham.sieve
{% endif %}
}

View File

@ -0,0 +1,16 @@
protocol imap {
mail_plugins = $mail_plugins imap_old_stats
}
plugin {
old_stats_refresh = 30 secs
}
service old-stats {
fifo_listener old-stats-mail {
user = vmail
mode = 0600
}
inet_listener {
address = 127.0.0.1
port = 24242
}
}

View File

@ -37,7 +37,7 @@ $CONF['default_aliases'] = array (
{% endfor %} {% endfor %}
); );
$CONF['admin_email'] = '{{ mailserver_postfixadmin_mail_admin }}'; $CONF['admin_email'] = '{{ mailserver_postfixadmin_mail_admin }}';
$CONF['admin_name'] = 'Hosting of {{ mailserver_postfixadmin_mail_domain }}'; $CONF['admin_name'] = 'Hosting of {{ mailserver_mail_domain }}';
$CONF['password_validation'] = array( $CONF['password_validation'] = array(
# '/regular expression/' => '$PALANG key (optional: + parameter)', # '/regular expression/' => '$PALANG key (optional: + parameter)',