From b9d4e0b0d030f1254118c0b8e9466407b8310365 Mon Sep 17 00:00:00 2001 From: Crest Date: Mon, 4 Jul 2022 02:44:47 +0200 Subject: [PATCH] Use s6 path variables for Dovecot Updates #31 --- roles/dovecot/handlers/main.yml | 6 +++--- roles/dovecot/tasks/main.yml | 14 +++++++------- roles/dovecot/templates/acme_dovecot.j2 | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/roles/dovecot/handlers/main.yml b/roles/dovecot/handlers/main.yml index a2c707e..d9f519e 100644 --- a/roles/dovecot/handlers/main.yml +++ b/roles/dovecot/handlers/main.yml @@ -5,10 +5,10 @@ state: reloaded - name: Reload Dovecot - command: s6-svc -h /run/service/dovecot + command: s6-svc -h {{ s6_scan_dir }}/dovecot - name: Restart Dovecot - command: s6-svc -wR -T 5000 -ru /run/service/dovecot + command: s6-svc -wR -T 5000 -ru {{ s6_scan_dir }}/dovecot - name: Restart Dovecot log - command: s6-svc -wR -T 5000 -ru /run/service/dovecot-log + command: s6-svc -wR -T 5000 -ru {{ s6_scan_dir }}/dovecot-log diff --git a/roles/dovecot/tasks/main.yml b/roles/dovecot/tasks/main.yml index 01cde91..bec60a0 100644 --- a/roles/dovecot/tasks/main.yml +++ b/roles/dovecot/tasks/main.yml @@ -63,7 +63,7 @@ - name: Create Dovecot service directories file: - path: '/etc/s6-rc/service/{{ item }}' + path: '{{ s6_etc_dir }}/service/{{ item }}' state: directory owner: root group: wheel @@ -76,7 +76,7 @@ - name: Generate Dovecot service scripts template: - dest: '/etc/s6-rc/service/{{ item }}' + dest: '{{ s6_etc_dir }}/service/{{ item }}' src: '{{ item }}.j2' mode: 0555 owner: root @@ -89,7 +89,7 @@ - name: Generate Dovecot service configuration copy: - dest: '/etc/s6-rc/service/{{ item.name }}' + dest: '{{ s6_etc_dir }}/service/{{ item.name }}' content: '{{ item.content }}' mode: 0444 owner: root @@ -123,7 +123,7 @@ group: acme regexp: '^DEPLOY_DOVECOT_PEM_PATH=' state: present - line: 'DEPLOY_DOVECOT_RELOAD="sudo s6-svc -h /run/service/dovecot"' + line: 'DEPLOY_DOVECOT_RELOAD="sudo s6-svc -h {{ s6_scan_dir }}/dovecot"' - name: Flush handlers meta: flush_handlers @@ -137,20 +137,20 @@ group: wheel - name: Deploy X.509 certificate to Dovecot - command: 'env sudo -Hu acme acme.sh --debug --home /var/db/acme --install-cert --domain {{ ansible_fqdn }} --cert-file /usr/local/etc/dovecot/cert.pem --key-file /usr/local/etc/dovecot/privkey.pem --fullchain-file /usr/local/etc/dovecot/fullchain.pem --reloadcmd "sudo s6-svc -h /run/service/dovecot"' + command: 'env sudo -Hu acme acme.sh --debug --home /var/db/acme --install-cert --domain {{ ansible_fqdn }} --cert-file /usr/local/etc/dovecot/cert.pem --key-file /usr/local/etc/dovecot/privkey.pem --fullchain-file /usr/local/etc/dovecot/fullchain.pem --reloadcmd "sudo s6-svc -h {{ s6_scan_dir }}/dovecot"' args: creates: /usr/local/etc/dovecot/fullchain.pem notify: - Reload Dovecot - name: Start Dovecot - command: fdmove -c 2 1 s6-rc -u -v 2 -t 15000 change dovecot + command: fdmove -c 2 1 s6-rc -l {{ s6_live_dir }} -u -v 2 -t 15000 change dovecot register: change changed_when: change.stdout | length > 0 - name: Enable Dovecot lineinfile: - path: /etc/s6-rc/service/enabled/contents + path: '{{ s6_etc_dir }}/service/enabled/contents' regexp: "^dovecot$" line: dovecot state: present diff --git a/roles/dovecot/templates/acme_dovecot.j2 b/roles/dovecot/templates/acme_dovecot.j2 index af8e19c..0dcaa5d 100644 --- a/roles/dovecot/templates/acme_dovecot.j2 +++ b/roles/dovecot/templates/acme_dovecot.j2 @@ -1 +1 @@ -acme ALL=NOPASSWD:/usr/local/bin/s6-svc -h /run/service/dovecot +acme ALL=NOPASSWD:/usr/local/bin/s6-svc -h {{ s6_scan_dir }}/dovecot