# copy action with\_fileglob always skips files in 1.2

**URL:** <https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975>\
**Category:** Ansible Project\
**Created:** [June 17, 2013, 6:57pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975 "2013-06-17T18:57:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Stern](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dave\_Stern](https://forum.ansible.com/u/Dave_Stern)\
**Post date:** [June 17, 2013, 6:57pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/1 "2013-06-17T18:57:04Z")

</div>

The pattern mentioned here is failing for me in 1.2:  
[http://www.ansibleworks.com/docs/playbooks2.html#lookup-plugins-accessing-outside-data](http://www.ansibleworks.com/docs/playbooks2.html#lookup-plugins-accessing-outside-data)

I believe my playbook worked in 1.1, but every task that uses copy with\_fileglob always says it is “skipping:” these tasks with no other output in verbose mode (-vvv).  
This happens regardless of whether I use asterisks or exact filenames in the fileglob or whether I use $item or {{ item }}. Did I miss a setting or change in the syntax?

Examples:

- name: “nagios config: servers”  
copy: src={{ item }} dest=/etc/nagios3/servers/ owner=root group=root mode=644  
with\_fileglob:

- roles/admin/files/etc/nagios3/servers/_._  
notify:

- restart nagios

- name: bash env dotfiles  
copy: src={{ item }} dest=/home/username/ owner=username group=username mode=744  
with\_fileglob:

- roles/admin/files/home/username/.env\_file

OR

- name: bash env dotfiles  
copy: src={{ item }} dest=/home/username/ owner=username group=username mode=744  
with\_fileglob:
- roles/admin/files/home/username/\*

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [June 17, 2013, 7:00pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/2 "2013-06-17T19:00:49Z")

</div>

Dave:

This bit me the other day, so I submitted a doc patch which got accepted, from the link you sent:

Note

When using `with_fileglob` or `with_file` with [_Roles_](http://www.ansibleworks.com/docs/playbooks.html#roles), if you specify a relative path (e.g., `./foo`), Ansible resolves the path relative to the `roles/<rolename>/files` directory.

Zap the “roles/admin/files/” from your path, and it should work, e.g.:

with\_fileglob:

- etc/nagios3/servers/_._

Lorin

---

<div class="post-metadata">

**Author:** ![Dave\_Stern](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dave\_Stern](https://forum.ansible.com/u/Dave_Stern)\
**Post date:** [June 17, 2013, 7:09pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/3 "2013-06-17T19:09:25Z")

</div>

Lorin,

Thank you so much, that worked!

Also, for others who may read this, this is also the case with the src= attribute of copy if you are specifying the full path to a file. In other words, these both worked for me:

copy: src=roles/admin/files/etc/apache2/sites-available/default-ssl dest=/etc/apache2/sites-available/ owner=root group=root mode=644

AND

copy: src=etc/apache2/sites-available/default-ssl dest=/etc/apache2/sites-available/ owner=root group=root mode=644

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [June 18, 2013, 3:26am UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/4 "2013-06-18T03:26:35Z")

</div>

Slight clarification is that it looks in the “files/” directory if and only if the files directory exists.

But yes!

---

<div class="post-metadata">

**Author:** ![Dave\_Stern](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dave\_Stern](https://forum.ansible.com/u/Dave_Stern)\
**Post date:** [June 18, 2013, 6:17pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/5 "2013-06-18T18:17:33Z")

</div>

Is there a similar default path in the templates module?

I have a template with a relative path and ansible is assuming it is in the templates dir.

- name: coord config  
template: src=opt/app/conf/coord.cfg.template dest=/opt/app/conf/coord.cfg owner=username group= username mode=644 backup=no

Running this produces an error:

input file not found at /path/to/app/templates/opt/app/conf/coord.cfg.template

the file is actually store in

roles/app/files/opt/app/conf/coord.cfg.template

I now realize templates may be a better place for it than files, but I’m still curious about the behavior. As far as I have found in my searches, this is undocumented, but perhaps I missed it?

---

<div class="post-metadata">

**Author:** ![Scott\_Sturdivant](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Scott\_Sturdivant](https://forum.ansible.com/u/Scott_Sturdivant)\
**Post date:** [June 18, 2013, 6:21pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/6 "2013-06-18T18:21:09Z")

</div>

Yes, see this: [http://www.ansibleworks.com/docs/bestpractices.html#directory-layout](http://www.ansibleworks.com/docs/bestpractices.html#directory-layout).

---

<div class="post-metadata">

**Author:** ![Dave\_Stern](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dave\_Stern](https://forum.ansible.com/u/Dave_Stern)\
**Post date:** [June 18, 2013, 6:24pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/7 "2013-06-18T18:24:06Z")

</div>

That makes sense as a best practice. May I suggest documenting more clearly that these are also the defaults that ansible uses in relative paths?  
If that is documented anywhere, I had a hard time finding it.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [June 18, 2013, 6:28pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/8 "2013-06-18T18:28:37Z")

</div>

Yes, upgrades to the documentation are welcome! You may send in patches to the github repo at docsite/latest/rst/\*.rst.

---

<div class="post-metadata">

**Author:** ![Dave\_Stern](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dave\_Stern](https://forum.ansible.com/u/Dave_Stern)\
**Post date:** [June 18, 2013, 6:29pm UTC](https://forum.ansible.com/t/copy-action-with-fileglob-always-skips-files-in-1-2/12975/9 "2013-06-18T18:29:35Z")

</div>

Very cool. Thank you and will do!
