Repository navigation
Force template module to use non-native Jinja2 - #68560
Conversation
This comment has been minimized.
This comment has been minimized.
|
Would it make sense to create a whole new integration target for this, with the idea that it's a whole class of potential problems we might need to expand over time? |
Good point, I'll do that. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6d25c17 to
7f7eb91
Compare
Fixes ansible#46169 ci_complete
09626ab to
32ffb71
Compare
sivel
left a comment
There was a problem hiding this comment.
This looks good, just a couple of easy comments.
| variable_end_string=variable_end_string, | ||
| available_variables=vars, searchpath=searchpath): | ||
| if USE_JINJA2_NATIVE: | ||
| res = templar.do_template(template_data, preserve_trailing_newlines=True, |
There was a problem hiding this comment.
Can we add a comment about why we call .do_template for native instead of .template?
There was a problem hiding this comment.
Looking at this again (because of course I forgot why I did that), the reason is effectively to bypass Templar.is_possibly_template call in Templar.template. If we had '{\n "key": "bar"\n}\n' as an input for is_possibly_template, that would not be considered as a template and the original string would be returned. With native jinja2 we probably want it templated so it's turned into a dict. So I think what we should do here instead is to use .template for native and non-native in the template lookup and add (yet another) if USE_JINJA2_NATIVE check to is_possibly_template to always return True for native.
Sigh...
There was a problem hiding this comment.
So this turned out not to be a good idea as it broke the below task. Since set_fact is templated once and the result is stored (as opposed to a vars:), the below could be re-templated causing string (there are double quotes) being turned into integer.
- set_fact:
foo: "'{{ integer_bar }}'"So it created more problems and calling .template for both native and non-native is what I ended up with.
32ffb71 to
8f506f4
Compare
|
!waffling core_review |
SUMMARY
Fixes #46169
ci_complete
ISSUE TYPE
COMPONENT NAME
Jinja2 native types
template module