Comments (8)
This is not a module issue. This is because you are using jinja templating. Unfortunately due to how jinja2 works, it technically only has the ability to return strings. Any time you use jinja2 templating, the result comes out as a string. So while |int is internally converting the value to an int, the final result from jinja2 is a string. This has been discussed here: ansible/ansible#30366
The good news is there was a change implemented in jinja to preserve the native types. You can add the following in the [default] section of ansible.cfg
jinja2_native = True
With above, integer value wont convert to a string, while using jinja template. You also dont need a int filter now. Can you please try that. I was able to use your playbook (minus the int filter) successfully with above change in ansible.cfg
from community.aws.
Thank you @jainnikhil30 for the long answer. The jinja2_native
configuration key is documented here https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-jinja2-native and requires Ansible 2.7 or greater and an up to date version of Jinja2 (>= 2.10).
@leedm777 I close the PR, feel free to reopen if you think we've missed something.
from community.aws.
Is there a way to do
jinja2_native
on just one task or play? I have a huge stack of playbooks that all expect the default behavior. Changing it so this one value converts correctly then breaks dozens of other tasks.
Based on the documentation that @goneri sent here, you can configure the environment variable at the task level so that this does not effect the entire playbook/play:
ANSIBLE_JINJA2_NATIVE: true
from community.aws.
@leedm777 Let us know if @jainnikhil30's solution works for you? Thanks.
from community.aws.
@jainnikhil30, enabling jinja2_native
does indeed work.
Although given Jinja2's default behavior of "everything returns a string", I would've expected either Ansible or the module itself to be more lenient and parse strings that get passed in for numeric fields. That said, I'm good with enabling jinja2_native
and moving on.
Thanks!
from community.aws.
cc @jillr @s-hertel @tremble @wimnat
click here for bot help
from community.aws.
Is there a way to do jinja2_native
on just one task or play? I have a huge stack of playbooks that all expect the default behavior. Changing it so this one value converts correctly then breaks dozens of other tasks.
from community.aws.
@sky-amoncadot I very much appreciate the reply as I went looking for that specific understanding and have still yet to find documentation that clearly explains how one changes a configuration setting at the task level. I know it's a tangent to this issue, but how does one infer from Ansible Configuration Settings which of the keys used in a playbook keyword context?
- The section is labeled
DEFAULT_JINJA2_NATIVE
- The ini key is
jinja2_native
- The env var is
ANSIBLE_JINJA2_NATIVE
Searching on other settings I've seen altered in plays, like become_user
, I'm guessing it's the ini key of jinja2_native
. I'm up for doing the documentation PR myself, but it just struck me odd that it's assumed knowledge.
from community.aws.
Related Issues (20)
- s3settings sample not found [community.aws.dms_endpoint]
- Indentation inconsistent on cloudfront_distribution module
- aws_api_gateway only creates REST-API and not HTTP
- Integration tests need to be updated to avoid unsafe templating HOT 1
- Add support for "skip_matching" preference in autoscaling_instance_refresh
- Typo in autoscaling_instance_refresh module in check mode HOT 1
- Unable to connect with SSM on Amazon Linux 2023 based instances HOT 6
- Allow bulk deletion of ECS Task Definitions HOT 1
- etag module util missing unit tests
- Implement Support for Amazon EFS Archive Storage Class and Elastic Mode in Ansible EFS Module
- aws workspaces inventory plugin HOT 1
- SSM Connection: Failed to create temporary directory HOT 2
- Add possibility to create AWS Network Load Balancer with attached Security Group
- Add throughput mode elastic for efs HOT 1
- api_gateway doesn't create a new deployment when API Gateway already exists
- eks_cluster should be able to upgrade cluster versions
- aws_ssm remote directory / HOT 4
- Add task to get a list of all ECS clusters HOT 2
- s3_lifecycle module should allow setting the ChecksumAlgorithm argument to AWS SDK put_bucket_lifecycle_configuration() call
- s3_lifecycle encounters error KeyError: 'Rules' when there are no lifecycle configuration rules on bucket HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from community.aws.