From 618f756458a976585e7980ce13d3f3e7047fe64d Mon Sep 17 00:00:00 2001 From: chsteinle Date: Tue, 21 Dec 2021 07:45:41 +0100 Subject: [PATCH] Find old backup files for semaphore playbook. --- semaphore.yaml | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/semaphore.yaml b/semaphore.yaml index 603c044..3e01a71 100644 --- a/semaphore.yaml +++ b/semaphore.yaml @@ -121,6 +121,69 @@ loop_control: label: "{{ item.path }}" + - name: Find old daily backups + find: + paths: "{{ item.path | dirname }}/daily" + file_type: file + age: 8d + age_stamp: ctime + patterns: '*.gz' + recurse: false + register: old_files + with_items: "{{ backup_files.results | map(attribute='files') | list }}" + loop_control: + label: "{{ item.path }}" + + - name: Print old files + debug: + var: old_files + +# - name: Delete old daily backups +# file: +# path: "{{ item.path }}" +# state: absent +# with_items: "{{ backup_files.results | map(attribute='files') | list }}" +# loop_control: +# label: "{{ item.path }}" +# +# - name: Find old weekly backups +# find: +# paths: "{{ backup_dir }}/{{ item }}/weekly" +# file_type: file +# age: 5w +# age_stamp: ctime +# patterns: '*.gz' +# recurse: false +# register: backup_files +# loop: "{{ systems }}" +# +# - name: Delete old weekly backups +# file: +# path: "{{ item.path }}" +# state: absent +# with_items: "{{ backup_files.results | map(attribute='files') | list }}" +# loop_control: +# label: "{{ item.path }}" +# +# - name: Find old monthly backups +# find: +# paths: "{{ backup_dir }}/{{ item }}/monthly" +# file_type: file +# age: 56w +# age_stamp: ctime +# patterns: '*.gz' +# recurse: false +# register: backup_files +# loop: "{{ systems }}" +# +# - name: Delete old monthly backups +# file: +# path: "{{ item.path }}" +# state: absent +# with_items: "{{ backup_files.results | map(attribute='files') | list }}" +# loop_control: +# label: "{{ item.path }}" + - name: Inform Mattermost about success uri: url: "{{ mattermost_url }}"