2022-01-07 20:13:43 +01:00
|
|
|
---
|
2022-01-10 14:19:53 +01:00
|
|
|
- name: (SCHEDULE) (SYSTEMD) create systemd timer
|
2022-10-06 14:52:27 +02:00
|
|
|
when:
|
|
|
|
- ansible_service_mgr == 'systemd'
|
|
|
|
- restic_schedule_type == "systemd"
|
|
|
|
- restic_create_schedule | bool
|
2022-01-07 20:13:43 +01:00
|
|
|
block:
|
2022-01-10 14:19:53 +01:00
|
|
|
- name: (SCHEDULE) (SYSTEMD) copy systemd timer
|
2022-01-07 20:13:43 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: templates/restic.timer.j2
|
|
|
|
dest: "/lib/systemd/system/restic-{{ item.name | replace(' ', '') }}.timer"
|
|
|
|
owner: 'root'
|
|
|
|
group: 'root'
|
|
|
|
mode: '0644'
|
|
|
|
no_log: "{{ restic_no_log }}"
|
|
|
|
with_items: '{{ restic_backups }}'
|
|
|
|
notify: systemctl restart restic.timer
|
|
|
|
when:
|
|
|
|
- item.name is defined
|
|
|
|
- item.scheduled | default(false)
|
|
|
|
|
2022-01-10 14:19:53 +01:00
|
|
|
- name: (SCHEDULE) (SYSTEMD) copy systemd service
|
2022-01-07 20:13:43 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: templates/restic.service.j2
|
|
|
|
dest: "/lib/systemd/system/restic-{{ item.name | replace(' ', '') }}.service"
|
|
|
|
owner: 'root'
|
|
|
|
group: 'root'
|
|
|
|
mode: '0644'
|
|
|
|
no_log: "{{ restic_no_log }}"
|
|
|
|
with_items: '{{ restic_backups }}'
|
|
|
|
when:
|
|
|
|
- item.name is defined
|
|
|
|
- item.scheduled | default(false)
|
|
|
|
|
2022-01-10 14:19:53 +01:00
|
|
|
- name: (SCHEDULE) (SYSTEMD) Enable restic service
|
2022-01-07 20:13:43 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "restic-{{ item.name | replace(' ', '') | string }}.service"
|
|
|
|
enabled: true
|
|
|
|
daemon_reload: true
|
|
|
|
masked: false
|
|
|
|
with_items: '{{ restic_backups }}'
|
|
|
|
notify: systemctl restart restic.timer
|
|
|
|
when:
|
|
|
|
- item.name is defined
|
|
|
|
- item.scheduled | default(false)
|
|
|
|
|
2022-01-10 14:19:53 +01:00
|
|
|
- name: (SCHEDULE) (SYSTEMD) Enable and start restic timer
|
2022-01-07 20:13:43 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "restic-{{ item.name | replace(' ', '') | string }}.timer"
|
|
|
|
enabled: true
|
|
|
|
state: started
|
|
|
|
daemon_reload: true
|
|
|
|
masked: false
|
|
|
|
with_items: '{{ restic_backups }}'
|
|
|
|
notify: systemctl restart restic.timer
|
|
|
|
when:
|
|
|
|
- item.name is defined
|
|
|
|
- item.scheduled | default(false)
|
|
|
|
rescue:
|
2022-10-06 14:52:27 +02:00
|
|
|
- name: Set cronjob intead of systemd
|
2022-04-01 11:07:12 +02:00
|
|
|
ansible.builtin.set_fact:
|
2022-01-07 20:13:43 +01:00
|
|
|
restic_force_cron: true
|