I would like to use ansible to delete older files. I have a data log folder, inside this folder I have multiple directories:
/data/log/folder1/
/data/log/folder2/
....
I tried to use this ansible playbook :
---
- hosts: all
tasks:
- name: find all files that are older than 10 days
find:
paths: /data/log/*/
age: 10d
recursive: yes
register: filesOlderThan10
- name: remove older than 10
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ (filesOlderThan10.files }}"
When I launch the playbook nothing is deleted, I'm not sure that I could use this syntax /data/log/*/
I am therefore looking for suggestions to improve this code