Currently I have it configured as such: 
- 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 | difference([unc_path]) }}"


You're suggesting replacing "unc_path" with "item.path" in the second name 
block as such: 


On Wednesday, May 12, 2021 at 2:00:02 PM UTC-7 [email protected] wrote:

> You are looking win_file with the values of FilesOver30.files but setting 
> the path for each of those loops to unc_path. This will just run the same 
> thing, deleting that UNC path for every loop iteration. What you want to do 
> is set 'path: "{{ item.path }}"' so that path is set to each of the found 
> paths that you got in the previous step.
>
> On Thursday, May 13, 2021 at 6:06:07 AM UTC+10 [email protected] wrote:
>
>> On Wed, 12 May 2021 at 21:44, Jeremy Smith <[email protected]> wrote: 
>> > 
>> > I've read the documentation at the link you provided and am unsure how 
>> any of that can help me. There is no other list than FilesOver30.files to 
>> compare it with. 
>>
>> >> >> - name: Delete all files/folders older than 30 days from 
>> diagnostics folder 
>> >> >> win_file: 
>> >> >> path: "{{ unc_path }}" 
>> >> >> state: absent 
>> >> >> with_items: "{{ FilesOver30.files }}" 
>>
>> If I understand your problem description correctly, the value of 
>> "unc_path" is in the FIlesOver30.files list. 
>> You can remove it by the difference of a list containing a single 
>> item: the unc_path. 
>>
>>
>> with_items: "{{ FilesOver30.files | difference([unc_path]) }}" 
>>
>>
>>
>>
>>
>>
>>
>> -- 
>> Dick Visser 
>> Trust & Identity Service Operations Manager 
>> GÉANT 
>>
>

-- 
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/3dde7b5c-5f7e-47c2-961a-7e2516a4cd49n%40googlegroups.com.

Reply via email to