diff --git a/letsencrypt-acme-sh-client/tasks/main.yml b/letsencrypt-acme-sh-client/tasks/main.yml index d9eb6d5c..4e9afff3 100644 --- a/letsencrypt-acme-sh-client/tasks/main.yml +++ b/letsencrypt-acme-sh-client/tasks/main.yml @@ -34,6 +34,10 @@ - acme-sh-cron-command tags: [ 'letsencrypt', 'letsencrypt_cron', 'letsencrypt_acme_sh' ] + - name: Install a daily cron job to renew the certificates when needed. It runs as root + cron: name="Letsencrypt certificate renewal" day={{ letsencrypt_acme_cron_day_of_month }} hour={{ letsencrypt_acme_cron_hour }} minute={{ letsencrypt_acme_cron_minute }} job="/usr/local/bin/acme-sh-cron-script > {{ letsencrypt_acme_sh_log_dir }}/acme-cron.log 2>&1" + tags: [ 'letsencrypt', 'letsencrypt_cron', 'letsencrypt_acme_sh' ] + when: letsencrypt_acme_sh_install tags: [ 'letsencrypt', 'letsencrypt_acme_sh' ] @@ -62,8 +66,8 @@ notify: Install the requested certificates ignore_errors: True - - name: Install a daily cron job to renew the certificates when needed - cron: name="Letsencrypt certificate renewal" day={{ letsencrypt_acme_cron_day_of_month }} hour={{ letsencrypt_acme_cron_hour }} minute={{ letsencrypt_acme_cron_minute }} job="/usr/local/bin/acme-sh-cron-script > {{ letsencrypt_acme_sh_log_dir }}/acme-cron.log 2>&1" + - name: Remove the daily cron job that run as acme user. + cron: name="Letsencrypt certificate renewal" day={{ letsencrypt_acme_cron_day_of_month }} hour={{ letsencrypt_acme_cron_hour }} minute={{ letsencrypt_acme_cron_minute }} job="/usr/local/bin/acme-sh-cron-script > {{ letsencrypt_acme_sh_log_dir }}/acme-cron.log 2>&1" state=absent tags: [ 'letsencrypt', 'letsencrypt_cron', 'letsencrypt_acme_sh' ] become: True