Hello All, 

Background: We have a "diagnostics" folder on our network that is used to 
store logs exported from our flagship application. 

The problem I'm trying to solve is to remove any files/folders older than 
30 days from the "diagnostics" folder. 

The following code is being used to perform this: 
- name: Find all files older than 30 days in diagnostics folder
    win_find: 
        paths: "{{ unc_path }}"
        file_type: directory
        age: 30d
        #recurse: yes
    register: FilesOver30

  - name: Delete all files/folders older than 30 days from diagnostics folder
    win_file:
      path: "{{ unc_path }}"
      state: absent
    with_items: "{{ FilesOver30.files }}"

The issue I'm having is, if there are no files newer than 30 days in the 
"diagnostics" folder, it actually nukes the diagnostics folder itself, 
which is not the intended result. 

Need to be able to have it remove any files/folders older than 30 days from 
this folder witout nuking the entire thing. 

Thanks in advance for the feedback! 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/17e3a87f-61c4-4861-bd6b-b6442368a7cfn%40googlegroups.com.

Reply via email to