Merge pull request #17 from roles-ansible/handlers

restart restic timer if something changed
This commit is contained in:
L3D 2021-07-07 11:24:07 +02:00 committed by GitHub
commit a82f54c0f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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'
no_log: true
with_items: '{{ restic_backups }}'
notify: systemctl restart restic.timer
when:
- restic_create_cron
- item.name is defined
@ -53,6 +54,7 @@
enabled: true
daemon_reload: true
with_items: '{{ restic_backups }}'
notify: systemctl restart restic.timer
when:
- restic_create_cron
- item.name is defined
@ -66,6 +68,7 @@
state: started
daemon_reload: true
with_items: '{{ restic_backups }}'
notify: systemctl restart restic.timer
when:
- restic_create_cron
- item.name is defined

View file

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

View file

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