--- /dev/null
+# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+- name: Checkout configuration
+ command: |
+ git --work-tree=/tmp --git-dir=/srv/git/server.git checkout main --force \
+ dovecot/*
+ become: yes
+- name: Install dovecot
+ package:
+ name:
+ - dovecot-imapd
+ - dovecot-lmtpd
+ - dovecot-pgsql
+ state: latest
+ become: yes
+- name: Ensure dovecot directory structure exists
+ file:
+ path: "/etc/dovecot/conf.d"
+ state: directory
+ become: yes
+- name: Copy to /etc/dovecot
+ copy:
+ src: "/tmp/dovecot/{{ item }}"
+ dest: "/etc/dovecot"
+ remote_src: true
+ become: true
+ with_items:
+ - dovecot-dict-auth.conf.ext
+ - dovecot-dict-sql.conf.ext
+ - dovecot-sql.conf.ext
+ - dovecot.conf
+- name: Copy to /etc/dovecot/conf.d
+ copy:
+ src: "/tmp/dovecot/{{ item }}"
+ dest: "/etc/dovecot/conf.d"
+ remote_src: true
+ become: true
+ with_items:
+ - 10-auth.conf
+ - 10-master.conf
+ - 15-mailboxes.conf
+ - 90-plugin.conf
+ - auth-dict.conf.ext
+ - auth-static.conf.ext
+ - 10-director.conf
+ - 10-ssl.conf
+ - 20-imap.conf
+ - 90-quota.conf
+ - auth-master.conf.ext
+ - auth-system.conf.ext
+ - 10-logging.conf
+ - 10-tcpwrapper.conf
+ - 20-lmtp.conf
+ - auth-checkpassword.conf.ext
+ - auth-passwdfile.conf.ext
+ - 10-mail.conf
+ - 15-lda.conf
+ - 90-acl.conf
+ - auth-deny.conf.ext
+ - auth-sql.conf.ext
+- name: Ensure virtual mailbox exists
+ user:
+ name: "vmail"
+ home: "/var/vmail"
+ shell: "/usr/sbin/nologin"
+ password_lock: true
+ become: yes
+- name: Ensure log files exist
+ file:
+ path: "/var/log/{{ item }}"
+ state: touch
+ owner: vmail
+ group: vmail
+ become: yes
+ with_items:
+ - dovecot.log
+ - dovecot-info.log
+- name: Restart dovecot
+ service:
+ name: dovecot
+ state: restarted
+ become: yes