Dubby
Dubby

Reputation: 2412

Ansible with_fileglob is skipping

I am putting together an Ansible Playbook designed to build webservers. However I am stuck when trying to use with_fileglob because Ansible keeps reporting that it's skipping the copy of nginx vhost files.

My script looks like this:

 - name: Nginx | Copy vhost files
   copy: src={{ item }} dest=/etc/nginx/sites-available owner=root group=root  mode=600
   with_fileglob:
     - "{{ templates_dir }}/nginx/sites-available/*"  
   notify
   - nginx-restart:

{{ templates }} has been defined elsewhere as roles/common/templates. In this directory I have a file called webserver1 that I'm hoping Ansible will copy into /etc/nginx/sites-available/

I have found other people discussing this issue but no responses have helped me solve this problem. Why would Ansible be skipping files?

Edit: I should point out that I want to use with_fileglob (rather than straight copy) as I want to iterate over other virtual hosts in the future.

Upvotes: 11

Views: 16740

Answers (1)

asgalon
asgalon

Reputation: 171

Look at http://docs.ansible.com/playbooks_loops.html#looping-over-fileglobs, Note 1:

When using a relative path with with_fileglob in a role, Ansible resolves the path relative to the roles//files directory.

So to access a file in the templates directory, you can start the relative path with ../templates

Upvotes: 15

Related Questions