Allow config to enable native jinja types#32738
Allow config to enable native jinja types#32738mkrizek merged 29 commits intoansible:develfrom jctanner:JINJA_NATIVE_TYPES
Conversation
|
The initial patch here is pretty hacky, but feedback is very welcome. |
|
Is this something we would consider for v2.5 ? |
|
@dagwieers this is a message I got late last night ...
The current patch does just that. Off by default. |
There was a problem hiding this comment.
no need to do this here, AnsibleEnvironment inherits from Environment
There was a problem hiding this comment.
I would move the previous:
from jinja2 import Environment
into an 'else/pass' here to make the choice obvious vs the 'masking' of the previous import
There was a problem hiding this comment.
Wouldn't getattr(new_context, 'unsafe', False) be cleaner? (no idea about ansible code guidelines, just staw this PR when referenced in the related jinja PR
cognifloyd
left a comment
There was a problem hiding this comment.
Here, you only swap out the Environment. What about the Template?
How does AnsibleJ2Template compare with NativeTemplate?
AnsibleJ2Template overrides new_context() but NativeTemplate overrides render(). Does Ansible not use render()?
There was a problem hiding this comment.
What about doing the same with from jinja2.utils import concat as j2_concat?
There was a problem hiding this comment.
Cool. I think you can drop line 41 too.
|
This passed in shippable. The UNSTABLE status is because of an unrelated, transient failure in the opensuse repository for the zypper test. The second test run was fine. |
|
The test The test |
|
The test The test |
|
The test |
|
The test |
Co-authored-by: Martin Krizek <martin.krizek@gmail.com>
|
Forgive me my ignorance. But should this now be solved in devel? I'm using now the devel source from yesterday, but I still cannot get out proper integers. I'm using this playbook to test: https://gist.githubusercontent.com/jctanner/32df50fe270096afc7fe2582e2d21b8c/raw/6fbe189830de4b09d0e322e481fd458031674809/site.yml |
|
Did you set the config setting to true? |
|
@abadger Nope! Works now. 👍 Thanks for the heads up! |
|
For posterity, the |
Ansible cannot template numbers.
```
TACC_API_TIMEOUT: "{{ TACC_API_TIMEOUT }}"
```
Will result in a yaml string. Atmosphere expects this variable
to be a yaml number. Ansible fixed this issue in 2.7
ansible/ansible#32738 .
Until this is fixed, it is hardcoded.
Ansible cannot template numbers.
```
TACC_API_TIMEOUT: "{{ TACC_API_TIMEOUT }}"
```
Will result in a yaml string. Atmosphere expects this variable
to be a yaml number. Ansible fixed this issue in 2.7
ansible/ansible#32738 .
Until this is fixed, it is hardcoded.
|
Alternatively to the config file, |
SUMMARY
Allow config to enable native jinja types
ISSUE TYPE
COMPONENT NAME
templar
ANSIBLE VERSION
ADDITIONAL INFORMATION
Ties into the jinja 2.10 release feature http://jinja.pocoo.org/docs/2.10/nativetypes/