roles/certbot: Run periodically as certbot user
The default systemd unit configuration for *certbot-renew.service* runs the `certbot renew …` command as root. This can cause permissions issues, since this Ansible role expects the *certbot* user to be able to access all configuration, data, and log files. As such, this commit adds a systemd unit extension for *certbot-renew.service* to run the command as *certbot*.
This commit is contained in:
3
roles/certbot/files/certbot-renew-runas.service
Normal file
3
roles/certbot/files/certbot-renew-runas.service
Normal file
@@ -0,0 +1,3 @@
|
||||
[Service]
|
||||
User=certbot
|
||||
Group=certbot
|
||||
@@ -1,3 +1,5 @@
|
||||
- name: reload systemd
|
||||
command: systemctl daemon-reload
|
||||
- name: reload httpd
|
||||
service:
|
||||
name=httpd
|
||||
|
||||
@@ -92,6 +92,17 @@
|
||||
dest=/etc/sysconfig/certbot
|
||||
mode=0644
|
||||
|
||||
- name: ensure certbot renew service extension directory exists
|
||||
file:
|
||||
path=/etc/systemd/system/certbot-renew.service.d
|
||||
mode=0755
|
||||
state=directory
|
||||
- name: ensure certbot renew runs as certbot user
|
||||
copy:
|
||||
src=certbot-renew-runas.service
|
||||
dest=/etc/systemd/system/certbot-renew.service.d/run-as-certbot.conf
|
||||
mode=0644
|
||||
notify: reload systemd
|
||||
- name: ensure certbot timer is enabled
|
||||
service:
|
||||
name=certbot-renew.timer
|
||||
|
||||
Reference in New Issue
Block a user