I prepared a playbook as follows:
It's not clear what you are trying to do.
Depending on your use case you could either use fileglob:
https://docs.ansible.com/ansible/latest/plugins/lookup/fileglob.html
Or if you need to filter on specific permissions etc, use the find
module: https://docs.ansible.com/ansible/latest/modules/find_module.html
Dick
Not really clear why command or shell doesn’t meet your needs but take a look at find, file or stat perhaps. See full list of modules below:
https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html
Regards
Phil