refactored to timer routine

This commit is contained in:
2024-01-04 13:27:07 +01:00
parent 973e667b4f
commit 40f6f7dc4f
43 changed files with 152 additions and 335 deletions

View File

@@ -1,12 +1,6 @@
- name: "reload certbot service"
systemd:
name: certbot.service
name: nginx-certbot.service
state: reloaded
enabled: yes
daemon_reload: yes
- name: "restart certbot timer"
systemd:
name: certbot.timer
state: restarted
enabled: yes
daemon_reload: yes

View File

@@ -4,20 +4,24 @@
state: present
when: run_once_nginx_certbot is not defined
- name: configure certbot.service.tpl
- name: configure nginx-certbot.service
template:
src: certbot.service.j2
dest: /etc/systemd/system/certbot.service
src: nginx-certbot.service.j2
dest: /etc/systemd/system/nginx-certbot.service
notify: reload certbot service
when: run_once_nginx_certbot is not defined
- name: configure certbot.timer.tpl
template:
src: certbot.timer.j2
dest: /etc/systemd/system/certbot.timer
register: certbot_timer
changed_when: certbot_timer.changed or activate_all_timers | bool
notify: restart certbot timer
- name: set service_name to the name of the current role
set_fact:
service_name: "{{ role_name }}"
when: run_once_nginx_certbot is not defined
- name: "include role for systemd-timer for {{service_name}}"
include_role:
name: systemd-timer
vars:
on_calendar: "{{on_calendar_renew_lets_encrypt_certificates}}"
persistent: "true"
when: run_once_nginx_certbot is not defined
- name: run the nginx_certbot tasks once

View File

@@ -1,10 +0,0 @@
[Unit]
Description=Renewal of Let's Encrypt's certificates
[Timer]
OnCalendar=0/12:00:00
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=true
[Install]
WantedBy=timers.target