mirror of
https://github.com/geerlingguy/ansible-role-certbot.git
synced 2025-04-19 17:01:37 +02:00
Merge pull request #14 from geerlingguy/certbot-auto-renew
Fixes #13: Certbot auto renew cron job
This commit is contained in:
commit
222d57cb2e
17
README.md
17
README.md
@ -20,6 +20,13 @@ Certbot code repository options. This role clones the agent from the configured
|
|||||||
|
|
||||||
The directory inside which Certbot will be cloned.
|
The directory inside which Certbot will be cloned.
|
||||||
|
|
||||||
|
certbot_auto_renew: true
|
||||||
|
certbot_auto_renew_user: "{{ ansible_user }}"
|
||||||
|
certbot_auto_renew_hour: 3
|
||||||
|
certbot_auto_renew_minute: 30
|
||||||
|
|
||||||
|
By default, this role configures a cron job to run under the provided user account at the given hour and minute, every day. The defaults run `certbot-auto renew` via cron every day at 03:30:00 by the user you use in your Ansible playbook. It's preferred that you set a custom user/hour/minute so the renewal is during a low-traffic period and done by a non-root user account.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
None.
|
None.
|
||||||
@ -27,6 +34,12 @@ None.
|
|||||||
## Example Playbook
|
## Example Playbook
|
||||||
|
|
||||||
- hosts: servers
|
- hosts: servers
|
||||||
|
|
||||||
|
vars:
|
||||||
|
certbot_auto_renew_user: your_username_here
|
||||||
|
certbot_auto_renew_minute: 20
|
||||||
|
certbot_auto_renew_hour: 5
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- geerlingguy.certbot
|
- geerlingguy.certbot
|
||||||
|
|
||||||
@ -38,9 +51,7 @@ After installation, you can create certificates using the `certbot-auto` script,
|
|||||||
# Generate certs, but don't modify Apache configuration (safer).
|
# Generate certs, but don't modify Apache configuration (safer).
|
||||||
/opt/certbot/certbot-auto --apache certonly
|
/opt/certbot/certbot-auto --apache certonly
|
||||||
|
|
||||||
To set up renewals, you should run the following command periodically (e.g. once or twice per day):
|
By default, this role adds a cron job that will renew all installed certificates once per day at the hour and minute of your choosing.
|
||||||
|
|
||||||
/opt/certbot/certbot-auto renew --quiet --no-self-upgrade
|
|
||||||
|
|
||||||
You can test the auto-renewal (without actually renewing the cert) with the command:
|
You can test the auto-renewal (without actually renewing the cert) with the command:
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
---
|
---
|
||||||
|
# Where to get Certbot.
|
||||||
certbot_repo: https://github.com/certbot/certbot.git
|
certbot_repo: https://github.com/certbot/certbot.git
|
||||||
certbot_version: master
|
certbot_version: master
|
||||||
certbot_keep_updated: yes
|
certbot_keep_updated: yes
|
||||||
|
|
||||||
|
# Where to put Certbot.
|
||||||
certbot_dir: /opt/certbot
|
certbot_dir: /opt/certbot
|
||||||
|
|
||||||
|
# How to keep Certbot certs up to date.
|
||||||
|
certbot_auto_renew: true
|
||||||
|
certbot_auto_renew_user: "{{ ansible_user }}"
|
||||||
|
certbot_auto_renew_hour: 3
|
||||||
|
certbot_auto_renew_minute: 30
|
||||||
|
@ -10,3 +10,12 @@
|
|||||||
file:
|
file:
|
||||||
path: "{{ certbot_dir }}/certbot-auto"
|
path: "{{ certbot_dir }}/certbot-auto"
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Add cron job for 'certbot-auto renew' (if configured).
|
||||||
|
cron:
|
||||||
|
name: Certbot automatic renewal.
|
||||||
|
job: "{{ certbot_dir }}/certbot-auto renew --quiet --no-self-upgrade"
|
||||||
|
minute: "{{ certbot_auto_renew_minute }}"
|
||||||
|
hour: "{{ certbot_auto_renew_hour }}"
|
||||||
|
user: "{{ certbot_auto_renew_user }}"
|
||||||
|
when: certbot_auto_renew
|
||||||
|
@ -7,6 +7,14 @@
|
|||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Install cron (RedHat).
|
||||||
|
yum: name=cronie state=present
|
||||||
|
when: ansible_os_family == 'RedHat'
|
||||||
|
|
||||||
|
- name: Install cron (Debian).
|
||||||
|
apt: name=cron state=present
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- geerlingguy.git
|
- geerlingguy.git
|
||||||
- role_under_test
|
- role_under_test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user