Is there a way to simply tell ansible to output any jinja2 templates it would have created when an ansible playbook is run?
I.e., not deploy them but just dump them to local host
Thanks a bunch.
Is there a way to simply tell ansible to output any jinja2 templates it would have created when an ansible playbook is run?
I.e., not deploy them but just dump them to local host
Thanks a bunch.
Sorry I meant the output of the templating process on jinja2 template (i.e., after all the replacements are done on the template).
I don't know of a flag, no (wouldn't be easy to disable handlers,
prevent local filename collisions, etc).
You _could_ use the lookup() function to load the template as a
string, then use debug: to print the string out.
But you'd have to get any vars the template needed into scope to be
sure the template ran it would on a host.
So, not easy.
If you're asking because you want to test run a play, i find local VMs
much simpler.
Ive thought about this too, and would also like a way to do this, in the mean time, i wrote this script that i call jinjacat.py
`
#!/usr/bin/env python
import sys
import yaml
import jinja2
if len(sys.argv) != 3:
print “usage: jinjacat.py template.j2 variables.yaml”
exit()
with open(sys.argv[1]) as fp:
template = jinja2.Template(fp.read())
with open(sys.argv[2]) as fp:
vars = yaml.load(fp.read())
print(template.render(vars))
`