iterate with_file contents ?

I have some files under my role path dir :

`
ls roles/my-role/files/
file1 file2 file3

`

I can display the content of the file by running :
`

  • name: display contents

debug:
msg: “{{ item }}”
with_file:

  • “roles/my-role/files/file1”
    `

if in the last line I try something like :
`with_file:

  • “roles/my-role/files/*”

`

I get an error :

fatal: [localhost]: FAILED! => {"msg": "could not locate file in lookup: roles/my-role/files/*"}

Is there a way I can iterate inside the files directory and get the content ?

PS: I need the files content and note a list of the file names.

You need to use the fileglob, so something like this

- debug: msg="{{ lookup('file', item) }}"
   with_fileglob: roles/my-role/files/*

worked like a charm , thank you so much Kai Stian !