commit 3a875176cd2a001b9e109b0ad6080ef9bdedf069
parent d7115b71e81efe66619066346ef4d7fb899785cf
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 23 Feb 2021 18:47:15 +0100
parent d7115b71e81efe66619066346ef4d7fb899785cf
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 23 Feb 2021 18:47:15 +0100
roles/acme-redirect: better handling of cert renewal/creation
3 files changed, 28 insertions(+), 32 deletions(-)
diff --git a/roles/acme-redirect/handlers/main.yml b/roles/acme-redirect/handlers/main.yml @@ -15,3 +15,31 @@ when: - ansible_service_mgr == "systemd" listen: "Restart acme-redirect" + +- name: "Check that all defined domains are pointing to this server" + command: + cmd: acme-redirect check -q + register: acme_check + become: yes + become_user: acme-redirect + listen: "Restart acme-redirect" + +- fail: + msg: "Check of domains failed: {{acme_check.stdout}}" + when: + - acme_check.stdout | length > 0 + listen: "Restart acme-redirect" + +- name: "Renew(or create) certs" + command: + cmd: acme-redirect renew -q + register: acme_renew + become: yes + become_user: acme-redirect + listen: "Restart acme-redirect" + +- fail: + msg: "Renew of certs failed: {{acme_renew.stdout}}" + when: + - acme_renew.stdout | length > 0 + listen: "Restart acme-redirect"
diff --git a/roles/acme-redirect/tasks/main.yml b/roles/acme-redirect/tasks/main.yml @@ -21,13 +21,6 @@ - services.acme_redirect.enable is defined - services.acme_redirect.enable is true -- meta: flush_handlers - -- include: renew.yml - when: - - services.acme_redirect.enable is defined - - services.acme_redirect.enable is true - - include: remove.yml when: - services.acme_redirect.enable is defined
diff --git a/roles/acme-redirect/tasks/renew.yml b/roles/acme-redirect/tasks/renew.yml @@ -1,25 +0,0 @@ ---- - -- command: - cmd: acme-redirect check -q - register: acme_check - become: yes - become_user: acme-redirect - when: - - services.acme_redirect.enable is true - -- fail: - msg: "Check of Certs failed: {{acme_check.stdout}}" - when: - - acme_check.stdout | length > 0 - -- command: - cmd: acme-redirect renew -q - register: acme_renew - become: yes - become_user: acme-redirect - -- fail: - msg: "Renew of certs failed: {{acme_renew.stdout}}" - when: - - acme_renew.stdout | length > 0