edit: Ansible 2.0 has been released now, so the previous answer should work, and you can also now loop over fileglobs. Note this only works if you are running Ansible locally:
- file:
path: "{{item}}"
state: absent
with_fileglob:
- /tmp/test/file*
original answer:
I can't find a way to do this currently without dropping to the shell, however if you can drop to the shell to gather a list of files that match the pattern and save that as a variable, then you can loop over the file module with with_items
Ansible 2.0 will include a "find" module that would get the list for you: http://docs.ansible.com/ansible/find_module.html
Here's a couple of tasks that should do it in ansible 2.0, but I don't have it installed so I haven't tested it and may be accessing the results of the find module incorrectly.
- find:
paths: "/tmp/test"
patterns: "file*"
register: result
- file:
path: "{{item.path}}" #correction code
state: absent
with_items: result.files
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…