# Template file location best practice?

**URL:** <https://forum.ansible.com/t/template-file-location-best-practice/19934>\
**Category:** Ansible Project\
**Created:** [December 4, 2015, 1:42am UTC](https://forum.ansible.com/t/template-file-location-best-practice/19934 "2015-12-04T01:42:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Jones](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@Brian\_Jones](https://forum.ansible.com/u/Brian_Jones)\
**Post date:** [December 4, 2015, 1:42am UTC](https://forum.ansible.com/t/template-file-location-best-practice/19934/1 "2015-12-04T01:42:24Z")

</div>

Where should I locate files that Ansible template steps need? My developers want to locate the files next to their Java code. I want the template files located in the Ansible source repository under the roles/name/templates directories. If we optimize for developers, then when I deploy, I’ll need to checkout both the Ansible code and any git repositories containing templates, which seems brittle. Say I have a tomcat application and I want to deliver property files and config files for my application. The developers want these files to live next to their java code, not next to the Ansible code.

A - Templates next to the code:

app1 (developers for app1 just work here)  
±-- templates somewhere in the tree next to the java code

app2 (developers for app2 just work here)

±-- templates somewhere in the tree next to the java code

Ansible  
roles  
some-role-that-uses-templates  
references app1 files via path

some-other-role-that-uses-templates  
references app2 files via path

RESULT:

- Developers like where templates are
- Deployment process does not like where templates are. All 3 repositories have to be checked out to deploy.

B - Templates next to Ansible code:

app1

app2

Ansible  
roles  
some-role-that-uses-templates  
templates for app1 here

some-other-role-that-uses-templates

templates for app2 here

RESULT:

- Developers not happy because they have to edit two locations (app# + Ansible), and create two commits to modify code/deployment
- Deployment process is simplified, only checkout Ansible repository.

Or is there some third better way of doing this that I’m not aware of?

Brian

---

<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:** [December 4, 2015, 1:52am UTC](https://forum.ansible.com/t/template-file-location-best-practice/19934/2 "2015-12-04T01:52:10Z")

</div>

symlinks? submodules? both would work transparent to both devs and the  
deployment.

---

<div class="post-metadata">

**Author:** ![Brian\_Jones](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@Brian\_Jones](https://forum.ansible.com/u/Brian_Jones)\
**Post date:** [December 4, 2015, 2:07am UTC](https://forum.ansible.com/t/template-file-location-best-practice/19934/3 "2015-12-04T02:07:21Z")

</div>

If we used symlinks, we would need a script to create them after checkout. This however would not work on windows. So symlinks won’t work for us.

Git submodules might be a possibility but every time I’ve read about them the resulting complexities seemed to outweigh the benefits.

---

<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:** [December 4, 2015, 2:08am UTC](https://forum.ansible.com/t/template-file-location-best-practice/19934/4 "2015-12-04T02:08:14Z")

</div>

git allows you to check in symlinks and preserves them on checkout
