diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..4c1bc2c --- /dev/null +++ b/handlers/main.yml @@ -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' diff --git a/tasks/timer.yml b/tasks/timer.yml index 695b4a7..dfc6453 100644 --- a/tasks/timer.yml +++ b/tasks/timer.yml @@ -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 diff --git a/templates/restic.timer.j2 b/templates/restic.timer.j2 index 69ea2c8..e48a18a 100644 --- a/templates/restic.timer.j2 +++ b/templates/restic.timer.j2 @@ -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 diff --git a/vars/main.yml b/vars/main.yml index 5d48ccb..ca5e061 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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'