Files
ansible-collection-rear/roles/rear_remove/tasks/main.yml
Chris Hammer 7606a0c308
Some checks failed
Ansible Lint Pipeline / Ansible-Development-Pipeline (ansible-dev-centos) (push) Failing after 11s
Add cleanup check; task migration; Add ansible-lint action
2025-09-24 16:08:49 -04:00

30 lines
960 B
YAML

---
- name: Check ReaR Output details
ansible.builtin.stat:
path: "/var/lib/rear"
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']) }}"
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: 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