# Using with\_fileglob is not behaving how I expect it to, am I missing something?

**URL:** <https://forum.ansible.com/t/using-with-fileglob-is-not-behaving-how-i-expect-it-to-am-i-missing-something/25475>\
**Category:** Ansible Project\
**Created:** [September 13, 2017, 4:42pm UTC](https://forum.ansible.com/t/using-with-fileglob-is-not-behaving-how-i-expect-it-to-am-i-missing-something/25475 "2017-09-13T16:42:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Fisher](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@Ryan\_Fisher](https://forum.ansible.com/u/Ryan_Fisher)\
**Post date:** [September 13, 2017, 4:42pm UTC](https://forum.ansible.com/t/using-with-fileglob-is-not-behaving-how-i-expect-it-to-am-i-missing-something/25475/1 "2017-09-13T16:42:32Z")

</div>

I’m attempting to use the file module to delete some cruft left over after installing Wordpress and I’m getting a not found warning when the task executes. Not sure what I’m doing wrong…

On the target host, the path and files exist:

$ ls /var/www/wordpress  
$ backwpup\_30357501\_measurabl-plugins.2017-09-03.txt backwpup\_30357501\_wordpress.sql license.txt …

Task:

- name: Ensure old backup files do not exist  
file:  
path: “{{ item }}”  
state: absent  
with\_fileglob:
- /var/www/wordpress/backwpup\_\*

Output when running task:  
TASK [measurabl-wordpress : Ensure old backup files do not exist] \*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[WARNING]: Unable to find ‘/var/www/wordpress’ in expected paths.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 13, 2017, 4:49pm UTC](https://forum.ansible.com/t/using-with-fileglob-is-not-behaving-how-i-expect-it-to-am-i-missing-something/25475/2 "2017-09-13T16:49:36Z")

</div>

`with_fileglob` runs on the ansible “controller” (localhost), not on the remote target.

If you want to list files or directories on a remote target, I recommend using the `find` module, registering the results, and then using a `with_items` over the results in a later task.

---

<div class="post-metadata">

**Author:** ![Ryan\_Fisher](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@Ryan\_Fisher](https://forum.ansible.com/u/Ryan_Fisher)\
**Post date:** [September 13, 2017, 5:05pm UTC](https://forum.ansible.com/t/using-with-fileglob-is-not-behaving-how-i-expect-it-to-am-i-missing-something/25475/3 "2017-09-13T17:05:35Z")

</div>

Ah, I see. Thanks for the clarification.
