diff --git a/roles/dovecot/files/dovecot-cleanup.service b/roles/dovecot/files/dovecot-cleanup.service new file mode 100644 index 0000000000000000000000000000000000000000..2aab49f2de05b8597c92628c0ca788a8797ef0e8 --- /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 0000000000000000000000000000000000000000..22bf24ae59a79c06b7d48c1c1cb7a5b154172058 --- /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 a24d570b96cfc59f98bdc67293007ef85c4956c5..792196f035dcb4752205eaba2d60c6d8e549b75b 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