2021-01-14 22:47:29 +01:00
|
|
|
---
|
|
|
|
# Install and configure Dovecot
|
|
|
|
- name: Install Dovecot
|
|
|
|
apt:
|
2021-01-28 00:07:23 +01:00
|
|
|
update_cache: true
|
2021-01-14 22:47:29 +01:00
|
|
|
name:
|
|
|
|
- dovecot-core
|
|
|
|
- dovecot-imapd
|
|
|
|
- dovecot-managesieved
|
|
|
|
- dovecot-lmtpd
|
|
|
|
- dovecot-ldap
|
|
|
|
- dovecot-pop3d
|
2021-01-30 00:30:35 +01:00
|
|
|
register: apt_result
|
|
|
|
retries: 3
|
|
|
|
until: apt_result is succeeded
|
2021-01-14 22:47:29 +01:00
|
|
|
|
|
|
|
# Create the vmail user with UID and GID 5000
|
|
|
|
- name: Create vmail user
|
|
|
|
user:
|
|
|
|
name: vmail
|
|
|
|
uid: 5000
|
2021-01-30 00:30:35 +01:00
|
|
|
group: 5000
|
2021-01-14 22:47:29 +01:00
|
|
|
home: /var/vmail
|
|
|
|
|
|
|
|
# Create mail user seive directory with right ownernship and rights
|
|
|
|
- name: Create mail user sieve directory
|
|
|
|
file:
|
|
|
|
path: /var/vmail/sieve/global
|
|
|
|
state: directory
|
|
|
|
owner: vmail
|
|
|
|
group: vmail
|
|
|
|
mode: 0770
|
|
|
|
|
|
|
|
# Do the same for mailboxes
|
|
|
|
- name: Create mail user mailbox directory
|
|
|
|
file:
|
|
|
|
path: /var/vmail/mailboxes
|
|
|
|
state: directory
|
|
|
|
owner: vmail
|
|
|
|
group: vmail
|
|
|
|
mode: 0770
|
2021-01-17 12:47:58 +01:00
|
|
|
|
2021-01-28 00:11:36 +01:00
|
|
|
# Add the Dovecot configuration files (conf.d)
|
|
|
|
- name: Add Dovecot configuration in conf.d
|
2021-01-14 22:47:29 +01:00
|
|
|
template:
|
2021-01-30 00:38:15 +01:00
|
|
|
src: "conf.d/{{ item }}.j2"
|
2021-01-14 22:47:29 +01:00
|
|
|
dest: "/etc/dovecot/conf.d/{{ item }}"
|
|
|
|
mode: 0644
|
2021-01-30 00:34:54 +01:00
|
|
|
loop:
|
|
|
|
- "10-auth.conf"
|
|
|
|
- "10-mail.conf"
|
|
|
|
- "10-master.conf"
|
|
|
|
- "10-ssl.conf"
|
|
|
|
- "10-logging.conf"
|
|
|
|
notify: Restart dovecot
|
2021-01-28 00:11:36 +01:00
|
|
|
|
|
|
|
# Add the Dovecot configuration file outside of conf.d
|
|
|
|
- name: Add Dovecot configuration outside of conf.d
|
|
|
|
template:
|
|
|
|
src: "dovecot-ldap.conf.ext.j2"
|
2021-02-05 01:50:56 +01:00
|
|
|
dest: "/etc/dovecot/dovecot-ldap.conf.ext"
|
2021-01-28 00:11:36 +01:00
|
|
|
mode: 0600 # only legible by root
|
|
|
|
owner: root
|
2021-01-29 00:57:24 +01:00
|
|
|
group: root
|
2021-01-30 00:34:54 +01:00
|
|
|
notify: Restart dovecot
|