66 lines
1.5 KiB
YAML
66 lines
1.5 KiB
YAML
---
|
|
# Install and configure Dovecot
|
|
- name: Install Dovecot
|
|
apt:
|
|
update_cache: true
|
|
name:
|
|
- dovecot-core
|
|
- dovecot-imapd
|
|
- dovecot-managesieved
|
|
- dovecot-lmtpd
|
|
- dovecot-ldap
|
|
- dovecot-pop3d
|
|
register: apt_result
|
|
retries: 3
|
|
until: apt_result is succeeded
|
|
|
|
# Create the vmail user with UID and GID 5000
|
|
- name: Create vmail user
|
|
user:
|
|
name: vmail
|
|
uid: 5000
|
|
gid: 5000
|
|
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
|
|
|
|
# Add the Dovecot configuration files (conf.d)
|
|
- name: Add Dovecot configuration in conf.d
|
|
template:
|
|
src: "{{ item }}.j2"
|
|
dest: "/etc/dovecot/conf.d/{{ item }}"
|
|
mode: 0644
|
|
loop:
|
|
- "10-auth.conf"
|
|
- "10-mail.conf"
|
|
- "10-master.conf"
|
|
- "10-ssl.conf"
|
|
- "10-logging.conf"
|
|
- "auth-system.conf.ext"
|
|
notify: Restart dovecot
|
|
|
|
# Add the Dovecot configuration file outside of conf.d
|
|
- name: Add Dovecot configuration outside of conf.d
|
|
template:
|
|
src: "dovecot-ldap.conf.ext.j2"
|
|
dest: "/etc/dovecot/dovecot-ldap-conf.ext"
|
|
mode: 0600 # only legible by root
|
|
owner: root
|
|
mode: root
|
|
notify: Reload dovecot
|