Playbook
Configure Certificate Renewal
Automatic certificate renewal twice a day, with nginx reloaded after each renewal.
Category
Web servers
Time limit per server
5 minutes
Temporary failures
Not retried: run it again
Version
1.0
Supported systems
Ubuntu 22.04+, Debian 12+, RHEL-compatible 8+ (AlmaLinux, Rocky Linux, RHEL, CentOS Stream, Oracle Linux), Amazon Linux 2023+
When to use it
Once a server has Let's Encrypt certificates, so they renew by themselves and nginx serves each renewed certificate straight away. Let's Encrypt certificates last 90 days; without renewal, every site on the server goes insecure on the same day. Run Install Certbot first.
This playbook has no options.
What it does on the server
- Turns on the Certbot package's own renewal timer:
certbot.timeron Ubuntu and Debian,certbot-renew.timerfrom EPEL on the RHEL family (off by default there), or the snap's timer. Where none exists, it installsiap-certbot-renew.timer, which runscertbot renewat midnight and noon with up to an hour's random delay. - Installs
/etc/letsencrypt/renewal-hooks/deploy/iap-reload-nginx.sh, which reloads nginx after each renewal, and only whennginx -tpasses. - Reports when the timer runs next.
- Warns about any certificate set to renew with Certbot's standalone server, which cannot work while nginx holds port 80.
It does not request certificates.
After the run
Run Check Certificate Renewal to prove renewal works end to end, and add an SSL certificate monitor in Monitoring so you are warned if a certificate ever gets close to expiring.
Common problems
"Certbot is not installed. Run Install Certbot first." — Run Install Certbot, then this playbook again.
"These certificates renew with Certbot's standalone server" — Those certificates were obtained another way and will fail to renew while nginx runs. Obtain them again with Configure Reverse Proxy, which uses the webroot method.