Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible with_fileglob is skipping

Tags:

ansible

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.

like image 236
Dubby Avatar asked Feb 07 '14 12:02

Dubby


1 Answers

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

like image 91
asgalon Avatar answered Nov 02 '22 23:11

asgalon