1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_restic.git synced 2024-12-11 23:41:32 +01:00

restart restic timer if something changed

This commit is contained in:
L3D 2021-07-07 11:20:37 +02:00
parent c961e1b281
commit 1870c78534
Signed by: l3d
GPG key ID: CD08445BFF4313D1
4 changed files with 18 additions and 2 deletions

13
handlers/main.yml Normal file
View file

@ -0,0 +1,13 @@
---
- name: systemctl restart restic.timer
become: true
ansible.builtin.systemd:
name: "restic-{{ item.name | replace(' ', '') | string }}.timer"
state: 'restarted'
daemon_reload: true
with_items: '{{ restic_backups }}'
when:
- restic_create_cron
- item.name is defined
- item.scheduled | default(false)
- ansible_service_mgr == 'systemd'

View file

@ -11,6 +11,7 @@
mode: '0644' mode: '0644'
no_log: true no_log: true
with_items: '{{ restic_backups }}' with_items: '{{ restic_backups }}'
notify: systemctl restart restic.timer
when: when:
- restic_create_cron - restic_create_cron
- item.name is defined - item.name is defined
@ -53,6 +54,7 @@
enabled: true enabled: true
daemon_reload: true daemon_reload: true
with_items: '{{ restic_backups }}' with_items: '{{ restic_backups }}'
notify: systemctl restart restic.timer
when: when:
- restic_create_cron - restic_create_cron
- item.name is defined - item.name is defined
@ -66,6 +68,7 @@
state: started state: started
daemon_reload: true daemon_reload: true
with_items: '{{ restic_backups }}' with_items: '{{ restic_backups }}'
notify: systemctl restart restic.timer
when: when:
- restic_create_cron - restic_create_cron
- item.name is defined - item.name is defined

View file

@ -4,7 +4,7 @@ Description=Run restic backup {{ item.name }} every night
[Timer] [Timer]
OnCalendar={{ restic_systemd_timer_default_OnCalendar }} OnCalendar={{ restic_systemd_timer_default_OnCalendar }}
RandomizedDelaySec={{ restic_systemd_timer_randomizeddelaysec }} RandomizedDelaySec={{ restic_systemd_timer_randomizeddelaysec }}
Persistent=yes Persistent=true
[Install] [Install]
WantedBy=timers.target WantedBy=timers.target

View file

@ -10,5 +10,5 @@ restic_os_variables:
paths: paths:
- 'vars' - 'vars'
playbook_version_number: 11 # should be int playbook_version_number: 12 # should be int
playbook_version_path: 'do1jlr.restic.version' playbook_version_path: 'do1jlr.restic.version'