ansible-mailserver-debian/mail_system/tasks/dovecot.yml
2026-03-22 13:09:26 +01:00

87 lines
2.1 KiB
YAML

# here we assume that postfix.yml has run such that user 'mailstore' exists
# sieve scripts
- name: Install dovecot packages
ansible.builtin.apt:
name: dovecot-core,dovecot-flatcurve,dovecot-imapd,dovecot-lmtpd,dovecot-managesieved,dovecot-pgsql,dovecot-sieve
state: present
- name: Remove inclusion of conf.d/*.conf from dovecot.conf
ansible.builtin.lineinfile:
path: /etc/dovecot/dovecot.conf
regexp: '^!include conf\.d/\*\.conf'
line: '#!include conf.d/*.conf'
- name: Set dovecot_config_version to 2.4.1
ansible.builtin.lineinfile:
path: /etc/dovecot/dovecot.conf
regexp: '^dovecot_config_version = .*'
line: 'dovecot_config_version = 2.4.1'
- name: Set dovecot_storage_version to 2.4.1
ansible.builtin.lineinfile:
path: /etc/dovecot/dovecot.conf
regexp: '^dovecot_storage_version = .*'
line: 'dovecot_storage_version = 2.4.1'
- name: Install /etc/dovecot/local.conf
ansible.builtin.template:
src: "dovecot/{{ item }}"
dest: "/etc/dovecot/{{ item }}"
owner: root
group: root
mode: "0600"
force: true
loop:
- local.conf
- name: File quota-warning.sh
ansible.builtin.template:
src: dovecot/quota-warning.sh
dest: /usr/local/bin/quota-warning.sh
owner: root
group: root
mode: "0755"
force: true
- name: Directory /var/lib/dovecot/sieve
ansible.builtin.file:
path: "/var/lib/dovecot/sieve"
state: directory
owner: mailstore
group: mailstore
mode: "0755"
- name: Copy sieve files
ansible.builtin.copy:
src: dovecot/sieve
dest: /var/lib/dovecot/
owner: mailstore
group: mailstore
mode: "0600"
directory_mode: "0755"
- name: Directory permissions sieve pipes
ansible.builtin.file:
path: "/var/lib/dovecot/sieve/pipes"
owner: mailstore
group: mailstore
mode: "0777"
- name: Execution flag for spam training scripts
ansible.builtin.file:
path: "/var/lib/dovecot/sieve/pipes/{{ item }}"
owner: mailstore
group: mailstore
mode: "0700"
loop:
- rspamd-learn-spam.sh
- rspamd-learn-ham.sh
- name: Restart dovecot
ansible.builtin.systemd:
name: dovecot
state: restarted