-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fix native type conversion in json_template #154
Fix native type conversion in json_template #154
Conversation
Fixes ansible-network#151 * The current implementation tries to convert the value to int irrespective to the actual desired type of data. * Ansible version 2.7 onwards supports native jinja2 types eg: value: "{{ item.name.acl_name|float }}" To convert to native jinja2 type by default need to set `jinja2_native` config varaible in `defaults` setion within configuration file. Note: this required jinja2 version to be >= 2.10
ab2b443
to
af60ec2
Compare
Build failed.
|
Build succeeded.
|
@ganeshrn We need to put this in Doc that this feature is only supported with Ansible 2.7 and requires jinja2 version to be >= 2.10. This cannot be backported. |
Build failed.
|
docs/directives/parser_directives.md
Outdated
|
||
**Note** | ||
Native jinja2 datatype (eg. 'int', 'float' etc.) rendering is supported with Ansible version >= 2.7 | ||
and jinja2 library version >= 2.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add an example?
Build failed.
|
Fixes #151
The current
json_template
implementation tries to convert the value to int irrespective to theactual type of data.
Ansible version 2.7 onwards supports native jinja2 types conversion. Refer JSON templating incorrectly changes the value to type int #151 (comment)
eg: value: "{{ item.name.acl_name|float }}"
To convert to native jinja2 type by default need to set
jinja2_native
config varaible indefaults
section of active Ansible config file.
Note: This feature require jinja2 version to be >= 2.10