Loop with a filter applied to a list

Hi all,

I'm having trouble creating a list of file names to loop over. I've tried
this, but it doesn't work:

- name: Debug
debug:
msg: "{{ item }}"
loop: "{{ query('fileglob', 'dir/*') | basename) }}"

I get an error:

An exception occurred during task execution. To see the full traceback, use
-vvv. The error was: AttributeError: 'list' object has no attribute 'rfind'

I'm using Ansible 2.5.5

query return a list, basename can't run on a list only string, so move you basename to the item in msg.

Got it: loop: "{{ query('fileglob', 'dir/*') | map('basename') | list) }}"