ansible_role_restic/tasks/restic_delete_systemd.yml
2022-01-10 14:19:53 +01:00

58 lines
2 KiB
YAML

---
- name: (SCHEDULE) (SYSTEMD) remove systemd timer
block:
- name: (SCHEDULE) (SYSTEMD) mask restic timer
become: true
ansible.builtin.systemd:
name: "restic-{{ item.name | replace(' ', '') | string }}.timer"
enabled: false
state: stopped
daemon_reload: true
masked: false
with_items: '{{ restic_backups }}'
ignore_errors: true
failed_when: false
changed_when: false
when:
- item.name is defined
- item.scheduled | default(false)
- restic_schedule_type == "cronjob" or restic_force_cron | default(false)
- name: (SCHEDULE) (SYSTEMD) mask restic service
become: true
ansible.builtin.systemd:
name: "restic-{{ item.name | replace(' ', '') | string }}.service"
enabled: false
state: stopped
daemon_reload: true
masked: true
with_items: '{{ restic_backups }}'
when:
- item.name is defined
- item.scheduled | default(false)
- restic_schedule_type == "cronjob" or restic_force_cron | default(false)
ignore_errors: true
failed_when: false
changed_when: false
- name: (SCHEDULE) (SYSTEMD) delete systemd .timer file
become: true
ansible.builtin.file:
path: "/lib/systemd/system/restic-{{ item.name | replace(' ', '') }}.timer"
state: absent
with_items: '{{ restic_backups }}'
when:
- item.name is defined
- item.scheduled | default(false)
- restic_schedule_type == "cronjob" or restic_force_cron | default(false)
- name: (SCHEDULE) (SYSTEMD) delete systemd .service file
become: true
ansible.builtin.file:
path: "/lib/systemd/system/restic-{{ item.name | replace(' ', '') }}.service"
state: absent
with_items: '{{ restic_backups }}'
when:
- item.name is defined
- item.scheduled | default(false)
- restic_schedule_type == "cronjob" or restic_force_cron | default(false)