Switches from cron to systemd

This commit is contained in:
Nikolaos Kakouros 2017-09-06 22:11:17 +02:00
parent f00a0ba181
commit 3e46e4ba8f
6 changed files with 41 additions and 1 deletions

8
handlers/main.yml Normal file
View File

@ -0,0 +1,8 @@
---
- name: Restart certbot-renew service
service:
name: certbot-renew
state: restarted
enabled: true
listen: restart-certbot-renew-service

View File

@ -7,5 +7,5 @@
- include: install-from-source.yml - include: install-from-source.yml
when: certbot_install_from_source when: certbot_install_from_source
- include: renew-cron.yml - include: systemd.yml
when: certbot_auto_renew when: certbot_auto_renew

13
tasks/systemd.yml Normal file
View File

@ -0,0 +1,13 @@
---
- name: Create certbot-renew service
template:
src: certbot-renew.service.j2
dest: /etc/systemd/system/certbot-renew.service
notify: restart-certbot-renew-service
- name: Create certbot-renew timer
template:
src: certbot-renew.timer
dest: /etc/systemd/system/certbot-renew.timer
notify: restart-certbot-renew-service

View File

@ -0,0 +1,9 @@
[Unit]
Description=Let's Encrypt renewal
[Service]
User={{ certbot_auto_renew_user }}
Type=oneshot
ExecStart={{ certbot_script }} renew --quiet --agree-tos
ExecStartPost=/bin/systemctl reload {{ certbot_web_service }}.service

View File

@ -0,0 +1,9 @@
[Unit]
Description=Periodically check for Let's Encrypt's certificates renewal
[Timer]
OnCalendar=*-*-* {{ certbot_auto_renew_hour }}:{{ certbot_auto_renew_minute }}:00
Persistent=true
[Install]
WantedBy=timers.target

View File

@ -1 +1,2 @@
certbot_package: letsencrypt certbot_package: letsencrypt
certbot_web_service: apache2