win_find and nested loops

I’m attempting to write a playbook using the win_find module. We are looking for files in a set of specific directories that are older than 30 days.

I’m able to get a list of files from the playbook, but getting all the way down to the path is escaping me. I think I have a handle on nested loops, but since these two loops are connected, I’m having a hard time putting it together.

My win_dir task:

  • name: “Finding files older than 30 days”
    win_find:
    paths: “{{ item }}”
    age: 30d
    register: list_30days
    loop: “{{ day30_dir }}”

I’m just struggling to get the path from list_30days.results with a nested loop. I can make it to “{{ item.files }}”, just can’t seem to loop over that list.

Thanks in advance.

Hello,

Don’t think this is an AWX specific topic, but you can use the json_query filter to access the path of the file.

Good luck!

Yeah, thought about that after I had posted it.

I did end up figuring it out by looking at the Ansible documentation on loops.

Thanks for the response.