display error when hook fails

5-trigger-hooks-after-certificate-renewal
HgO 2020-12-25 23:06:54 +01:00
parent f2eaece8cb
commit 3d975b1f17
2 changed files with 8 additions and 2 deletions

View File

@ -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():

View File

@ -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 }}