expansion of int values sometimes gives strings (when member of object) #19757
Labels
affects_2.2
This issue/PR affects Ansible v2.2
bug
This issue/PR relates to a bug.
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
ISSUE TYPE
COMPONENT NAME
core / vars expansion
ANSIBLE VERSION
CONFIGURATION
N/A
OS / ENVIRONMENT
Ubuntu 16.04
SUMMARY
A variable assignment can pass through a simple numeric value, but not a numeric value from a member of an object - in that case it gets silently converted to a string.
STEPS TO REPRODUCE
EXPECTED RESULTS
a, b and c are the number 5; the values of a+1, b+1 and c+1 are 6.
ACTUAL RESULTS
That is, the value of c is a string not a number.
STEPS TO REPRODUCE
Here is another example, this time using the
vars
option to thetemplate
module. The final test case, using with_items, is the actual use case which bit me.templates/test.j2
foo.yml
EXPECTED RESULTS
In both cases, the template would be expanded with
num
equal to the number 5.ACTUAL RESULTS
That is, in the with_items case, the value is string "5" rather than number 5.
WORKAROUND
Change the template so it says:
But this seems very arbitrary. Surely an integer value is always an integer value?
The text was updated successfully, but these errors were encountered: