2022-01-07 20:13:43 +01:00
|
|
|
---
|
2022-01-10 14:19:53 +01:00
|
|
|
- name: "(SCHEDULE) (OLD) check if ansible version is under 2.12.0"
|
2022-01-07 20:13:43 +01:00
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
|
|
|
- "ansible_version.full is version_compare('2.12.0', '<')"
|
|
|
|
fail_msg: "[ERROR] Youre ansible version is above 2.12.0"
|
|
|
|
success_msg: "Congratulations. You are using ansible version {{ ansible_version.full }}"
|
|
|
|
delegate_to: localhost
|
2023-03-22 01:18:23 +01:00
|
|
|
when:
|
|
|
|
- ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
|
|
|
|
register: old_af
|
|
|
|
failed_when: false
|
2023-03-22 00:39:40 +01:00
|
|
|
ignore_errors: true
|
2022-01-07 20:13:43 +01:00
|
|
|
|
2022-01-10 14:19:53 +01:00
|
|
|
- name: (SCHEDULE) (OLD) try to remove entries from /etc/crontab
|
2022-10-06 14:52:27 +02:00
|
|
|
become: true
|
2022-01-07 20:13:43 +01:00
|
|
|
ansible.builtin.cron:
|
|
|
|
name: "do1jlr.restic backup {{ item.name }}"
|
|
|
|
job: "CRON=true {{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
|
|
|
|
minute: '{{ item.schedule_minute | default("*") }}'
|
|
|
|
hour: '{{ item.schedule_hour | default("2") }}'
|
|
|
|
weekday: '{{ item.schedule_weekday | default("*") }}'
|
|
|
|
month: '{{ item.schedule_month | default("*") }}'
|
|
|
|
state: absent
|
2023-03-22 01:18:23 +01:00
|
|
|
cron_file: "/etc/crontab"
|
|
|
|
user: "root"
|
2022-01-07 20:13:43 +01:00
|
|
|
no_log: "{{ restic_no_log }}"
|
2023-03-22 01:18:23 +01:00
|
|
|
with_items: "{{ restic_backups }}"
|
2022-01-07 20:13:43 +01:00
|
|
|
when:
|
|
|
|
- restic_create_schedule | bool
|
|
|
|
- item.name is defined
|
|
|
|
- item.scheduled | default(false)
|
2023-03-22 01:18:23 +01:00
|
|
|
- old_af.success_msg is defined
|
2022-01-07 20:13:43 +01:00
|
|
|
register: cron_delete
|
2022-10-06 14:52:27 +02:00
|
|
|
failed_when: false
|
2022-01-07 20:13:43 +01:00
|
|
|
|
2022-10-06 14:52:27 +02:00
|
|
|
- name: "(SCHEDULE) (OLD) make sure do1jlr.restic backup script is not in /etc/crontab"
|
2022-01-07 20:13:43 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.lineinfile:
|
2023-03-22 01:18:23 +01:00
|
|
|
path: "/etc/crontab"
|
2022-01-07 20:13:43 +01:00
|
|
|
state: absent
|
|
|
|
search_string: "do1jlr.restic backup {{ item.name }}"
|
2023-03-22 01:18:23 +01:00
|
|
|
when: cron_delete.failed is defined and cron_delete.failed
|
|
|
|
with_items: "{{ restic_backups }}"
|
2022-01-07 20:13:43 +01:00
|
|
|
|
2022-10-06 14:52:27 +02:00
|
|
|
- name: "(SCHEDULE) (OLD) make sure restic script is not in /etc/crontab"
|
2022-01-07 20:13:43 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.lineinfile:
|
2023-03-22 01:18:23 +01:00
|
|
|
path: "/etc/crontab"
|
2022-01-07 20:13:43 +01:00
|
|
|
state: absent
|
|
|
|
search_string: "{{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
|
2023-03-22 01:18:23 +01:00
|
|
|
when: cron_delete.failed is defined and cron_delete.failed
|
|
|
|
with_items: "{{ restic_backups }}"
|