diff --git a/meta/runtime.yml b/meta/runtime.yml index 1b573f6..0d3cdbf 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,52 +1,4 @@ --- # Collections must specify a minimum required ansible version to upload # to galaxy -requires_ansible: '>=2.14.0' - -# Content that Ansible needs to load from another location or that has -# been deprecated/removed -# plugin_routing: -# action: -# redirected_plugin_name: -# redirect: ns.col.new_location -# deprecated_plugin_name: -# deprecation: -# removal_version: "4.0.0" -# warning_text: | -# See the porting guide on how to update your playbook to -# use ns.col.another_plugin instead. -# removed_plugin_name: -# tombstone: -# removal_version: "2.0.0" -# warning_text: | -# See the porting guide on how to update your playbook to -# use ns.col.another_plugin instead. -# become: -# cache: -# callback: -# cliconf: -# connection: -# doc_fragments: -# filter: -# httpapi: -# inventory: -# lookup: -# module_utils: -# modules: -# netconf: -# shell: -# strategy: -# terminal: -# test: -# vars: - -# Python import statements that Ansible needs to load from another location -# import_redirection: -# ansible_collections.ns.col.plugins.module_utils.old_location: -# redirect: ansible_collections.ns.col.plugins.module_utils.new_location - -# Groups of actions/modules that take a common set of options -# action_groups: -# group_name: -# - module1 -# - module2 +requires_ansible: '>=2.15.0' diff --git a/roles/rear_remove/tasks/main.yml b/roles/rear_remove/tasks/main.yml index c70e58f..1b3228f 100644 --- a/roles/rear_remove/tasks/main.yml +++ b/roles/rear_remove/tasks/main.yml @@ -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