Using with_fileglob is not behaving how I expect it to, am I missing something?

880 views
Skip to first unread message

Ryan Fisher

unread,
Sep 13, 2017, 12:42:32 PM9/13/17
to Ansible Project
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.

Matt Martz

unread,
Sep 13, 2017, 12:50:39 PM9/13/17
to ansible...@googlegroups.com
`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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/eb3339a4-9d6f-41c9-970c-e97155f5f512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Ryan Fisher

unread,
Sep 13, 2017, 1:05:35 PM9/13/17
to Ansible Project
Ah, I see. Thanks for the clarification.


On Wednesday, September 13, 2017 at 9:50:39 AM UTC-7, Matt Martz wrote:
`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.
On Wed, Sep 13, 2017 at 11:42 AM, Ryan Fisher <rfis...@gmail.com> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages