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
Not all spellings of boolean "false" in inventory are interpreted as false by Jinja #25784
Comments
@fthommen could you specify how you set I am not able to reproduce this issue defining the
|
I do it in the ansible inventory with switch=FALSE (http://docs.ansible.com/ansible/intro_inventory.html#host-variables) |
See 25778:
|
Thanks @pilou- . Very pity and IMHO somehow inconsistent. In this case - since that seems to be a design decision - please make this issue a documentation issue, not a bug report. |
btw I then still wonder, why "False" is interpreted as a boolean.... I can't find the notion of a boolean type in the Jinja documentation at all |
You need to specify type on 'consumption' we try to conserve it but both jinja2 and the ini format 'stringify everything'. This should give you more predictable results: |
@fthommen INI parser tries |
^ note that ast evals use 'python booleans' unlike jinja2 and yaml which use an extensive list. |
…#25798) * INI inventory: check variable types * INI inventory: add doc about variable types Fixes ansible#25784
ISSUE TYPE
COMPONENT NAME
inventory
template
jinja
ANSIBLE VERSION
CONFIGURATION
none special
OS / ENVIRONMENT
CentOS 7 on x86_64
SUMMARY
Boolean variables set in the inventory are not respected by Jinjia as one would expect. According to http://docs.ansible.com/ansible/YAMLSyntax.html e.g. the boolean value false can be written "false", "False", "FALSE" or "no". But only the exact spelling "False" is seen as false by Jinjia, all other spellings are seen as true value.
This is similar to and maybe related to (or the same problem as) #25778.
STEPS TO REPRODUCE
set "switch" to various values in the inventory.
EXPECTED RESULTS
switch=False: The switch is OFF (False)
switch=FALSE: The switch is OFF (FALSE)
switch=false: The switch is OFF (false)
switch=no: The switch is OFF (no)
switch=0: The switch is OFF (0)
switch=true: The switch is ON (true)
switch=blah: (not sure what to expect here, probably an error message)
ACTUAL RESULTS
echo results:
switch=False: The switch is OFF (False)
switch=FALSE: The switch is ON (FALSE)
switch=false: The switch is ON (false)
switch=no: The switch is ON (no)
switch=0: The switch is OFF (0)
switch=true: The switch is ON (true)
switch=blah: The switch is ON (blah)
The text was updated successfully, but these errors were encountered: