copy action with_fileglob always skips files in 1.2

3,037 views
Skip to first unread message

Dave Stern

unread,
Jun 17, 2013, 2:57:04 PM6/17/13
to ansible...@googlegroups.com
The pattern mentioned here is failing for me in 1.2:

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/*




Lorin Hochstein

unread,
Jun 17, 2013, 3:00:49 PM6/17/13
to ansible...@googlegroups.com
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, 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







--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Lorin Hochstein
Lead Architect - Cloud Services
Nimbis Services, Inc.

Dave Stern

unread,
Jun 17, 2013, 3:09:25 PM6/17/13
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Jun 17, 2013, 11:26:35 PM6/17/13
to ansible...@googlegroups.com
Slight clarification is that it looks in the "files/" directory if and only if the files directory exists.

But yes!
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Dave Stern

unread,
Jun 18, 2013, 2:17:33 PM6/18/13
to ansible...@googlegroups.com
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?

Scott Sturdivant

unread,
Jun 18, 2013, 2:21:09 PM6/18/13
to ansible...@googlegroups.com

Dave Stern

unread,
Jun 18, 2013, 2:24:06 PM6/18/13
to ansible...@googlegroups.com
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.

Michael DeHaan

unread,
Jun 18, 2013, 2:28:37 PM6/18/13
to ansible...@googlegroups.com
Yes, upgrades to the documentation are welcome!  You may send in patches to the github repo at docsite/latest/rst/*.rst.


Dave Stern

unread,
Jun 18, 2013, 2:29:35 PM6/18/13
to ansible...@googlegroups.com
Very cool. Thank you and will do!
Reply all
Reply to author
Forward
0 new messages