-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jinja includes in templates do not work as expected #15863
Comments
Hrm, I thought we had already solved this problem. @whiteinge How does this work when you're doing an import from a JSON file or similar? |
I believe Jinja includes are processed via Salt's file server same as |
master: 2014.1.7 /srv/salt/state/test/15863/another.txt:
/srv/salt/state/test/15863/file.txt:
/srv/salt/state/test/15863/init.sls:
pille@salt-master ~ % sudo salt -v 'tmp4*' state.sls test.15863 Executing job with jid 20140926093656911151 ------------------------------------------- tmp4: ---------- ID: /tmp/file.txt Function: file.managed Result: False Comment: Unable to manage file: Jinja error: another.txt Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/salt/utils/templates.py", line 261, in render_jinja_tmpl output = jinja_env.from_string(tmplstr).render(**unicode_context) File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 894, in render return self.environment.handle_exception(exc_info, True) File "", line 2, in top-level template code File "/usr/lib/pymodules/python2.7/salt/utils/jinja.py", line 122, in get_source raise TemplateNotFound(template) TemplateNotFound: another.txt ; line 2 --- this is file.txt, that should include another.txt when rendered. {% include "another.txt" %} <====================== Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/salt/utils/templates.py", line 261, in render_jinja_tmpl output = jinja_env.from_string(tmplstr).render(**unicode_context) File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 894, in render [...] --- Changes: Summary ------------ Succeeded: 0 Failed: 1 ------------ Total: 1 |
I bet this is related to #16106 |
If it is related to that issue, it has been resolved. @pille care to test? |
could reproduce the issue using minion from git develop (2014.7.0rc2-2427). |
Hmm, that should include the fix. I guess maybe this one is not related. Thanks for the update. |
@pille Sorry for the slow reply. The |
this might work if you want to move the file around.
|
Good suggestion. That addition is perfect for this. |
@whiteinge: i already tried that. it just throws the same error. |
your running a version of salt without the fix.
you will need to use the full path or update. |
@pille the paths in your base-case above are incorrect. After editing them this works correctly for me. Also, as @steverweber suggested, double-check the Salt version on your minion as well as your master.
|
my minion is git develop, but my master is running an old release. since i can't upgrade that for testing on-the-fly and @whiteinge provided info that it works, i'm closing this. thanks! |
probably because templates get parsed on the minion, when using the jinja
{% include "file.inc" %}
i get an template error, because the include is not found.
as a workaround you need to deploy that file.inc as a requirement.
i'm not sure if this is expected behaviour, or an issue. but currently i'm tending to treat it as a bug, since it completely fails when using
test=True
.The text was updated successfully, but these errors were encountered: