I have a playbook where I’m trying to use the find module to find files owned by a certain user. I’m trying to do register a variable to hold the files found for each folder within the loop as follows:
OK, so if I had 10 folders I was looping through, and set the register variable to “tmp_folder” for example, how would I know then loop through that 1 variable to pull out the info I need? The next step is to set a fact based on the returned files that match a certain user name. Would the fact be something like this:
set_fact:
temp_folder1_files: “{{ tmp_folder[0].files | selectattr(‘pw_name’, ‘equalto’, remove_user) | list }}”
temp_folder2_files: “{{ tmp_folder[1].files | selectattr(‘pw_name’, ‘equalto’, remove_user) | list }}”
temp_folder3_files: “{{ tmp_folder[2].files | selectattr(‘pw_name’, ‘equalto’, remove_user) | list }}”