diff --git a/tasks/dovecot.yml b/tasks/dovecot.yml index 7ca8d47..3768064 100644 --- a/tasks/dovecot.yml +++ b/tasks/dovecot.yml @@ -4,3 +4,31 @@ name: - dovecot - pigeonhole + +- name: dovecot create config folder + file: + path: "{{ item }}" + state: directory + mode: '0755' + with_items: + - /etc/dovecot + - /etc/dovecot/conf.d + +- name: take default dovecot config + copy: + remote_src: yes + src: "/usr/share/doc/dovecot/example-config/{{ item }}" + dest: "/etc/dovecot/{{ item }}" + with_items: + - conf.d/auth-sql.conf.ext + + +- name: dovecot config + template: + src: "dovecot/{{ item }}" + dest: "/etc/dovecot/{{ item }}" + with_items: + - dovecot-sql.conf.ext + - dovecot.conf + - conf.d/10-auth.conf + diff --git a/templates/dovecot/conf.d/10-auth.conf b/templates/dovecot/conf.d/10-auth.conf new file mode 100644 index 0000000..062860a --- /dev/null +++ b/templates/dovecot/conf.d/10-auth.conf @@ -0,0 +1,3 @@ +#auth_master_user_separator = * +auth_mechanisms = plain login +!include auth-sql.conf.ext diff --git a/templates/dovecot/dovecot-sql.conf.ext b/templates/dovecot/dovecot-sql.conf.ext new file mode 100644 index 0000000..e1cb320 --- /dev/null +++ b/templates/dovecot/dovecot-sql.conf.ext @@ -0,0 +1,9 @@ +driver = {{ mailserver_db_type }} +connect = host={{ mailserver_db_host }} dbname={{ mailserver_db_name }} user={{ mailserver_db_user }} password={{ mailserver_db_password }} + +default_pass_scheme = SHA512-CRYPT + +iterate_query = SELECT username AS user FROM mailbox + +user_query = SELECT '/srv/mail/mailboxes/%d/%n' as home, 'maildir:/srv/mail/mailboxes/%d/%n/Maildir' as mail, 5000 AS uid, 5000 AS gid, concat('dirsize:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1' +password_query = SELECT username as user, password, '/srv/mail/mailboxes/%d/%n' as userdb_home, 'maildir:/srv/mail/mailboxes/%d/%n/Maildir' as userdb_mail, 5000 as userdb_uid, 5000 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1' diff --git a/templates/dovecot/dovecot.conf b/templates/dovecot/dovecot.conf new file mode 100644 index 0000000..fcf1ac0 --- /dev/null +++ b/templates/dovecot/dovecot.conf @@ -0,0 +1,11 @@ +!include_try /usr/share/dovecot/protocols.d/*.protocol +protocols = imap lmtp sieve + +dict { + # Enable quota dictionnary + quota = {{ mailserver_db_type }}:/etc/dovecot/dovecot-dict-sql.conf.ext + #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext + +} +!include conf.d/*.conf +!include_try local.conf