From 1f87301fdb0caa83da8dccc8392eb856566580eb Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Wed, 27 Sep 2023 22:37:12 +0200 Subject: [PATCH] Add a script for configuring dovecot. --- server/dovecot.yaml | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 server/dovecot.yaml diff --git a/server/dovecot.yaml b/server/dovecot.yaml new file mode 100644 index 0000000..9762e8d --- /dev/null +++ b/server/dovecot.yaml @@ -0,0 +1,83 @@ +# Copyright (c) 2023 Jakub Czajka +# 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 -- 2.39.5