mirror of
https://github.com/roles-ansible/ansible_role_restic.git
synced 2024-12-11 23:41:32 +01:00
c62e2a4027
ignore_errors:true on the old version test. While the failure will not halt execution, it will color the summary output red for every host which executes the restic role even if most of them are set to use systemd Signed-off-by: Jeremy Hettenhouser <jhettenh@gmail.com>
49 lines
1.8 KiB
YAML
49 lines
1.8 KiB
YAML
---
|
|
- name: "(SCHEDULE) (OLD) check if ansible version is under 2.12.0"
|
|
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
|
|
ignore_errors: true
|
|
|
|
- name: (SCHEDULE) (OLD) try to remove entries from /etc/crontab
|
|
become: true
|
|
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
|
|
cron_file: '/etc/crontab'
|
|
user: 'root'
|
|
no_log: "{{ restic_no_log }}"
|
|
with_items: '{{ restic_backups }}'
|
|
when:
|
|
- restic_create_schedule | bool
|
|
- item.name is defined
|
|
- item.scheduled | default(false)
|
|
- ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
|
|
register: cron_delete
|
|
failed_when: false
|
|
|
|
- name: "(SCHEDULE) (OLD) make sure do1jlr.restic backup script is not in /etc/crontab"
|
|
become: true
|
|
ansible.builtin.lineinfile:
|
|
path: '/etc/crontab'
|
|
state: absent
|
|
search_string: "do1jlr.restic backup {{ item.name }}"
|
|
when: cron_delete.failed
|
|
with_items: '{{ restic_backups }}'
|
|
|
|
- name: "(SCHEDULE) (OLD) make sure restic script is not in /etc/crontab"
|
|
become: true
|
|
ansible.builtin.lineinfile:
|
|
path: '/etc/crontab'
|
|
state: absent
|
|
search_string: "{{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
|
|
when: cron_delete.failed
|
|
with_items: '{{ restic_backups }}'
|