diff --git a/files/acme_renew_cert.py b/files/acme_renew_cert.py index b5acfcd..261127f 100755 --- a/files/acme_renew_cert.py +++ b/files/acme_renew_cert.py @@ -308,7 +308,11 @@ class Domain(PrivateKey): def run_hooks(self) -> None: for hook in self.hooks: logging.info(f"Running hook: '{hook}'") - subprocess.run(hook.split()) + hook_res = subprocess.run(hook.split(), + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE) + if hook_res.returncode != 0: + logging.error(f"Unable to run hook: {hook_res.stderr}") def main(): diff --git a/tasks/main.yml b/tasks/main.yml index f1c5321..90a5757 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -84,7 +84,9 @@ tags: acme_install - name: Perform ACME challenge for each domain - command: acme-renew-cert -v -c {{ acme_config_file | quote }} + command: acme-renew-cert -c {{ acme_config_file | quote }} + changed_when: "'No domain to renew' not in _acme_challenge.stdout" + register: _acme_challenge tags: acme_challenge - name: Setup cron job for ACME certificates renewal of {{ domain_name }}