Template file location best practice?

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

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

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.

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