All checks were successful
Ansible Lint Pipeline / Ansible-Development-Pipeline (ansible-dev-centos) (push) Successful in 46s
43 lines
1.2 KiB
YAML
43 lines
1.2 KiB
YAML
---
|
|
- name: Check ReaR Output details
|
|
ansible.builtin.stat:
|
|
path: /boot/rear-initrd.cgz
|
|
register: file_details
|
|
|
|
- name: Check dates and cleanup ReaR backup as needed
|
|
when:
|
|
- file_details['stat']['exists'] | bool
|
|
block:
|
|
- name: Set current Date and ReaR file date
|
|
ansible.builtin.set_fact:
|
|
date_now: "{{ ansible_date_time['date'] }}"
|
|
file_date: "{{ '%Y-%m-%d' | strftime(file_details['stat']['mtime']) }}"
|
|
|
|
- name: Debug dates
|
|
ansible.builtin.debug:
|
|
msg: "{{ item }}"
|
|
verbosity: 1
|
|
loop:
|
|
- "{{ date_now }}"
|
|
- "{{ file_date }}"
|
|
|
|
- name: Compare dates to delete based on our retention policy
|
|
ansible.builtin.set_fact:
|
|
file_status: "{{ ((date_now | to_datetime('%Y-%m-%d')) - (file_date | to_datetime('%Y-%m-%d'))).days }}"
|
|
|
|
- name: Debug file_status
|
|
ansible.builtin.debug:
|
|
msg: "{{ file_status }}"
|
|
verbosity: 1
|
|
|
|
- name: Include cleanup tasks due to ReaR backup age
|
|
ansible.builtin.include_tasks: cleanup.yml
|
|
when:
|
|
- file_status|int >= 6
|
|
|
|
- name: Print message if ReaR file doesnt exist
|
|
ansible.builtin.debug:
|
|
msg: "The ReaR files don't exist on this server."
|
|
when:
|
|
- not file_details['stat']['exists'] | bool
|