From 495f4c4343680388d00b33685e568894f60abb63 Mon Sep 17 00:00:00 2001 From: Solal Nathan Date: Sat, 30 Jan 2021 00:02:28 +0100 Subject: [PATCH] User handlers to run when something changed --- roles/mail_certificates/handlers/main.yml | 3 +++ roles/mail_certificates/tasks/main.yml | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 roles/mail_certificates/handlers/main.yml diff --git a/roles/mail_certificates/handlers/main.yml b/roles/mail_certificates/handlers/main.yml new file mode 100644 index 0000000..cc3f463 --- /dev/null +++ b/roles/mail_certificates/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: Generate certificates + command: "certbot certonly --non-interactive --config /etc/letsencrypt/conf.d/{{ certbot.certname }}.ini" diff --git a/roles/mail_certificates/tasks/main.yml b/roles/mail_certificates/tasks/main.yml index 76f4b9c..2a4e30f 100644 --- a/roles/mail_certificates/tasks/main.yml +++ b/roles/mail_certificates/tasks/main.yml @@ -21,8 +21,4 @@ src: "conf.ini.j2" dest: "/etc/letsencrypt/conf.d/{{ certbot.certname }}.ini" mode: 0644 - register: certbot_config - -- name: Generate new certificates if the configuration changed - command: "certbot certonly --non-interactive --config /etc/letsencrypt/conf.d/{{ certbot.certname }}.ini" - when: certbot_config.changed + notify: Generate certificates