for instance using selectattr.
"{{ fs.files|selectattr('pw_name', 'equalto', 'some_user')|list }}"
On Thu, 1 Jul 2021 at 21:20, [email protected] <[email protected]> wrote:
>
> I'm trying to use the find module to search a path and return all files owned
> by a particular user. I can get the list of all files in the folder, but the
> data returned has both the path and the pw_name for each file. How can I
> narrow the search to return only files where pw_name is a certain user?
>
> ---
> - hosts: localhost
> become: yes
> become_method: sudo
> gather_facts: no
>
> tasks:
>
> - name: Find all files under /tmp
> find:
> paths: /tmp
> recurse: yes
> register: fs
>
> - name: Print output
> debug:
> msg: "{{ fs }}"
>
> What gets printed is every single file found, and fs.files has both path and
> pw_name. I want to only show any file where pw_name is the user I'm looking
> for.
>
> Any ideas?
>
> Thanks,
> Harry
>
> --
> 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/ac36dc28-a5a1-40d2-84af-c8d07384b65cn%40googlegroups.com.
--
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/CAL8fbwPsc3MKaECzzDsNp%3DVVpG3H_z4ya7u0d-tYii5ngkDOtA%40mail.gmail.com.