diff --git a/letsencrypt-acmetool-client/tasks/main.yml b/letsencrypt-acmetool-client/tasks/main.yml index 100f1d3..c429d20 100644 --- a/letsencrypt-acmetool-client/tasks/main.yml +++ b/letsencrypt-acmetool-client/tasks/main.yml @@ -122,12 +122,17 @@ - letsencrypt_certs_revoke_list is defined tags: letsencrypt +- name: Install a script that will be used to renew the certificate when needed + template: src=cron-acme-cert-request.j2 dest=/usr/local/bin/cron-acme-cert-request mode=0755 + when: letsencrypt_acme_install + tags: [ 'letsencrypt', 'letsencrypt_cron' ] + - name: Install a daily cron job to renew the certificates when needed become: True become_user: '{{ letsencrypt_acme_user }}' - cron: name="Letsencrypt certificate renewal" special_time=daily job="SLEEP_SECONDS=$(echo $[($RANDOM %1200)]) ; sleep ${SLEEP_SECONDS} ; /usr/local/bin/acme-cert-request > {{ letsencrypt_acme_log_dir }}/acme-cron.log 2>&1" + cron: name="Letsencrypt certificate renewal" special_time=daily job="/usr/local/bin/cron-acme-cert-request > {{ letsencrypt_acme_log_dir }}/acme-cron.log 2>&1" when: letsencrypt_acme_install - tags: letsencrypt + tags: [ 'letsencrypt', 'letsencrypt_cron' ] - name: letsencrypt acmetool request the first certificate become: True diff --git a/letsencrypt-acmetool-client/templates/cron-acme-cert-request.j2 b/letsencrypt-acmetool-client/templates/cron-acme-cert-request.j2 new file mode 100644 index 0000000..7e3dd9e --- /dev/null +++ b/letsencrypt-acmetool-client/templates/cron-acme-cert-request.j2 @@ -0,0 +1,12 @@ +#!/bin/bash + +CMD=/usr/local/bin/acme-cert-request + +SLEEP_SECONDS=$(echo $[($RANDOM %1200)]) +sleep ${SLEEP_SECONDS} + +/usr/local/bin/acme-cert-request +RETVAL=$? + +exit $RETVAL +