From 5adae994b6910b289cc8e68930ca15cbb16ce8a0 Mon Sep 17 00:00:00 2001 From: Frederik Schwan <frederik.schwan@linux.com> Date: Wed, 11 Nov 2020 18:13:28 +0100 Subject: [PATCH] add dovecot cleanup timer to purge mdbox files While mbox and maildir files get deleted by dovecot right away, that's not the case for mdbox files. Since they contain multiple mails at once in a proprietary format rewriting is expensive. That's why this step is done in a separate step outside the dovecot process. --- roles/dovecot/files/dovecot-cleanup.service | 6 ++++++ roles/dovecot/files/dovecot-cleanup.timer | 8 ++++++++ roles/dovecot/tasks/main.yml | 15 +++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 roles/dovecot/files/dovecot-cleanup.service create mode 100644 roles/dovecot/files/dovecot-cleanup.timer diff --git a/roles/dovecot/files/dovecot-cleanup.service b/roles/dovecot/files/dovecot-cleanup.service new file mode 100644 index 000000000..2aab49f2d --- /dev/null +++ b/roles/dovecot/files/dovecot-cleanup.service @@ -0,0 +1,6 @@ +[Unit] +Description=Daily Dovecot cleanup + +[Service] +Type=oneshot +ExecStart=/usr/bin/doveadm purge -A diff --git a/roles/dovecot/files/dovecot-cleanup.timer b/roles/dovecot/files/dovecot-cleanup.timer new file mode 100644 index 000000000..22bf24ae5 --- /dev/null +++ b/roles/dovecot/files/dovecot-cleanup.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Daily Dovecot cleanup + +[Timer] +OnCalendar=00:05:00 + +[Install] +WantedBy=timers.target diff --git a/roles/dovecot/tasks/main.yml b/roles/dovecot/tasks/main.yml index a24d570b9..792196f03 100644 --- a/roles/dovecot/tasks/main.yml +++ b/roles/dovecot/tasks/main.yml @@ -42,3 +42,18 @@ when: configure_firewall tags: - firewall + +- name: install systemd timers + copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644 + with_items: + - dovecot-cleanup.timer + - dovecot-cleanup.service + +- name: activate systemd timers + systemd: + name: "{{ item }}" + state: started + enabled: yes + daemon_reload: yes + with_items: + - dovecot-cleanup.timer -- GitLab