ansible-role-certbot: Permission denied: '/var/log/letsencrypt/.certbot.lock'
I’ve been seeing this coming from the daily cron job:
Cron username@somewhere.example.com certbot renew --quiet --no-self-upgrade
The following error was encountered:
[Errno 13] Permission denied: '/var/log/letsencrypt/.certbot.lock'
Either run as root, or set --config-dir, --work-dir, and --logs-dir to writeable paths.
Seems like it was set up to run as the user, not root?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 21 (2 by maintainers)
I missed this initially. The README states:
The run configuration didn’t match whatever was in
/etc/cron.d/certbotso it took me a while to reconcile:/etc/cron.d/certbot, which handles renewals, is supplied by the Debian package (tested on Ubuntu 18.04).To fix generally, it’s necessary to set
certbot_auto_renew_user: root, which perhaps we should be doing by default (although I understand the security implications of forcing users to be explicit about this). However, for Debian-based OSes, renewals should be skipped entirely as this is already handled.Workarounds
Debian-based OSes
Set the variable
certbot_auto_renew: false.Non Debian-based OSes
Set the variable
certbot_auto_renew_user: root.The role right now cannot be used to control the schedule or renewal on any system with systemd init. On ubuntu 20.04, there is
systemctl status certbot/etc/init.d/certbot: installed by certbot package. According to the notes in the file, systemd service has precedencecertbot_auto_renew_user) – installed by geerlingguy.certbot roleThe bottom line is that because of 1 & 2, the ansible role as is right now cannot be used to schedule or configure timing of the renewal.
As @colans suggested, use
certbot_auto_renew: falseand do not use the role’s scheduling as you will only duplicate the renewal job with what’s installed by the certbot package.It seems that the solution is for the geerlinguy.certbot role to work with systemd’s certbot service as it has precedence over
/etc/cron.d/certbot.@zeqk The Debian package handles renewals on its own via the
/etc/cron.d/certbotcron job.This is actually handled by Pull Request #80. Sadly getting PR through @geerlingguy is difficult because he has so many popular roles