Remote template

Hi,

Is there a practical way to use a remote file as a jinja template in template modules ?

Let’s explain my use case:

My application code requires configuration that may vary depending on the environment (dev/staging/prot)

I want to keep configuration defintion into application code, as j2 template, because it’s easier to maintain.

Those templates are deployed on the target machines along with the app, and then ansible creates final configuration files, using host/group variables.

Regards.

Hi,

Is there a practical way to use a remote file as a jinja template in
template modules ?

Combination of the fetch module and template module seems to be your
options here. Specifically
http://www.ansibleworks.com/docs/modules.html#fetch .

Let's explain my use case:

My application code requires configuration that may vary depending on the
environment (dev/staging/prot)

I want to keep configuration defintion into application code, as j2
template, because it's easier to maintain.

Those templates are deployed on the target machines along with the app,
and then ansible creates final configuration files, using host/group
variables.

Fun pattern; I'd be curious what your final implementation is for this. My
first inclination is that of "just centralize it in the repo- say via git
submodules", but that has it's own issues.

Cheers-
~brian

+1 to submodules, this way your playbook repo would have access to the template and those hijinks would not be required.

Hi,

I’m facing the same issue and wonder how you solved it?

something like?

template: src={{lookup('uri', 'http://remote.com/file.j2’}}

Can we do something like the “remote_src” parameter added in the “copy” module with Ansible 2.0? The use of “fetch” seems like a pretty awkward workaround. See another legitimate use case for this here:
http://stackoverflow.com/questions/33163204/ansible-remote-templates

that would require the remote machine to have jinja2 installed.