1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_restic.git synced 2024-12-11 23:41:32 +01:00

Merge pull request #94 from borland502/borland502-old-schedule-assert-patch

Fix play summary taint in legacy cron entry assertion for ansible past 2.12
This commit is contained in:
L3D 2023-03-22 12:15:08 +01:00 committed by GitHub
commit 1d7ba78515
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,11 @@
fail_msg: "[ERROR] Youre ansible version is above 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 }}" success_msg: "Congratulations. You are using ansible version {{ ansible_version.full }}"
delegate_to: localhost delegate_to: localhost
when:
- ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
register: old_af
failed_when: false
ignore_errors: true
- name: (SCHEDULE) (OLD) try to remove entries from /etc/crontab - name: (SCHEDULE) (OLD) try to remove entries from /etc/crontab
become: true become: true
@ -17,32 +22,32 @@
weekday: '{{ item.schedule_weekday | default("*") }}' weekday: '{{ item.schedule_weekday | default("*") }}'
month: '{{ item.schedule_month | default("*") }}' month: '{{ item.schedule_month | default("*") }}'
state: absent state: absent
cron_file: '/etc/crontab' cron_file: "/etc/crontab"
user: 'root' user: "root"
no_log: "{{ restic_no_log }}" no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}' with_items: "{{ restic_backups }}"
when: when:
- restic_create_schedule | bool - restic_create_schedule | bool
- item.name is defined - item.name is defined
- item.scheduled | default(false) - item.scheduled | default(false)
- ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob" - old_af.success_msg is defined
register: cron_delete register: cron_delete
failed_when: false failed_when: false
- name: "(SCHEDULE) (OLD) make sure do1jlr.restic backup script is not in /etc/crontab" - name: "(SCHEDULE) (OLD) make sure do1jlr.restic backup script is not in /etc/crontab"
become: true become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: '/etc/crontab' path: "/etc/crontab"
state: absent state: absent
search_string: "do1jlr.restic backup {{ item.name }}" search_string: "do1jlr.restic backup {{ item.name }}"
when: cron_delete.failed when: cron_delete.failed is defined and cron_delete.failed
with_items: '{{ restic_backups }}' with_items: "{{ restic_backups }}"
- name: "(SCHEDULE) (OLD) make sure restic script is not in /etc/crontab" - name: "(SCHEDULE) (OLD) make sure restic script is not in /etc/crontab"
become: true become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: '/etc/crontab' path: "/etc/crontab"
state: absent state: absent
search_string: "{{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh" search_string: "{{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
when: cron_delete.failed when: cron_delete.failed is defined and cron_delete.failed
with_items: '{{ restic_backups }}' with_items: "{{ restic_backups }}"