# Where to put templates/files outside of a role

**URL:** <https://forum.ansible.com/t/where-to-put-templates-files-outside-of-a-role/17459>\
**Category:** Ansible Project\
**Created:** [February 6, 2015, 2:06pm UTC](https://forum.ansible.com/t/where-to-put-templates-files-outside-of-a-role/17459 "2015-02-06T14:06:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kai\_Weber](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@Kai\_Weber](https://forum.ansible.com/u/Kai_Weber)\
**Post date:** [February 6, 2015, 2:06pm UTC](https://forum.ansible.com/t/where-to-put-templates-files-outside-of-a-role/17459/1 "2015-02-06T14:06:45Z")

</div>

Hi,

I am writing a role for varnish. Because Varnish configuration language is  
a "real" language I can and will not restrict what configuration a user can  
provide. To make it as flexible as possible I planned to use a variable with an  
empty default. So a user of my role can provide a complete VCL in a playbook  
like this:

- name: Configure varnish host  
&nbsp;&nbsp;hosts: 'proxy'  
&nbsp;&nbsp;sudo: True  
&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;varnish\_vcl\_content: |  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;backend default {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.host = foo  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.port = 80  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;- { role: varnish }

Now my questions:

1. Do you think, this is a good practice?

2. Is there a recommended directory for templates outside of role directories?  
&nbsp;&nbsp;&nbsp;Where would you put it? A user can fill the variable like this:

&nbsp;&nbsp;&nbsp;varnish\_vcl\_content: "{{ lookup('template', 'default.vcl') }}"

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 6, 2015, 2:50pm UTC](https://forum.ansible.com/t/where-to-put-templates-files-outside-of-a-role/17459/2 "2015-02-06T14:50:47Z")

</div>

Lookup plugins will search for relative paths by default in a role's  
files/ directory and then in a play's files/ directory.

Also you probably want to just use the file lookup plugin unless you  
are inserting jinja statements inside the default.vcl file.
