Skip to content

Commit

Permalink
Add a cron job to automatically renew the certificates and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
stevepiercy committed Mar 18, 2020
1 parent 605db56 commit f0cc209
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/webserver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ Or if you have the ``inventory_hostname`` variable defined:
certbot_hosts:
- "{{ inventory_hostname }}"
To automatically renew the certificates, you need to set the time you want to attempt renewal on a daily basis with the ``certbot_renew_at`` global variable.

.. code-block:: yaml
certbot_renew_at:
minute: 30
hour: 3
Remember, the ``certbot_hosts`` variable must be global, not part of ``webserver_virtualhosts`` list.
Also the ``certificate`` key and items under ``webserver_virtualhosts`` takes precedence over all other certificate management methods.
If you want to use certbot, then remove the ``certificate`` block.
Expand Down
10 changes: 10 additions & 0 deletions roles/certbot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@
- name: "Test renewal with a dry run."
shell: >
certbot renew --dry-run --nginx
- name: Cron job to auto renew certificates via certbot
when: certbot_renew_at|bool
cron:
name="Automatically renew Let's Encrypt certificates via certbot"
job="certbot renew --quiet --no-self-upgrade --nginx"
user=root
minute={{ item.minute }}
hour={{ item.hour }}
with_items: "{{ [certbot_renew_at] }}"

0 comments on commit f0cc209

Please sign in to comment.