Update checks and logic
All checks were successful
Ansible Lint Pipeline / Ansible-Development-Pipeline (ansible-dev-centos) (push) Successful in 46s
All checks were successful
Ansible Lint Pipeline / Ansible-Development-Pipeline (ansible-dev-centos) (push) Successful in 46s
This commit is contained in:
@ -1,29 +1,33 @@
|
||||
---
|
||||
- name: Check ReaR Output details
|
||||
ansible.builtin.stat:
|
||||
path: "/var/lib/rear"
|
||||
path: /boot/rear-initrd.cgz
|
||||
register: file_details
|
||||
|
||||
- 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: 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']) }}"
|
||||
when:
|
||||
- file_details['stat']['exists'] | bool
|
||||
|
||||
- name: Compare Dates to delete based on our 2 days retention policy
|
||||
ansible.builtin.set_fact:
|
||||
file_status: "{{ ((date_now | to_datetime('%Y-%m-%d')) - (file_date | to_datetime('%Y=%m-%d'))).days }}"
|
||||
when:
|
||||
- file_details['stat']['exists'] | bool
|
||||
- name: Compare Dates to delete based on our 2 days retention policy
|
||||
ansible.builtin.set_fact:
|
||||
file_status: "{{ ((date_now | to_datetime('%Y-%m-%d')) - (file_date | to_datetime('%Y-%m-%d'))).days }}"
|
||||
when:
|
||||
- file_details['stat']['exists'] | bool
|
||||
|
||||
# - name: Include Cleanup if the ReaR file is created 6 days back
|
||||
# ansible.builtin.include_tasks: cleanup.yml
|
||||
# when:
|
||||
# - not (file_status|int <= 6)
|
||||
- name: Include Cleanup if the ReaR file is created 6 days back
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when:
|
||||
- not (file_status|int <= 6)
|
||||
|
||||
- name: Print Msg 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
|
||||
- name: Print Msg 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
|
||||
|
Reference in New Issue
Block a user