Both issues appear to be related to some interaction between Jinja 3.0 and ansible-core 2.1x
My question is: what should we do about this in the system roles? Do we really have to go through all of our Jinja template code and ensure variables are “cast” to their correct type? Do we have to add requirements.txt, bindep, etc. to ensure that only the correct combinations of ansible-core and Jinja are used?
Both of these solutions seem wrong to me, unless we have been using variables incorrectly in Jinja for years now, and we really should have been “casting” the types all along.
That is - for some reason the variable timesync_step_threshold stops being a float inside the Jinja2 code block - and this only happens with certain combinations of ansible-core + jinja2
I think I’d need more evidence and context about how the role is being run, and if/how the user is specifying that value.
Regardless, the change is safe, and sane. It probably makes sense to cast them, especially if a caller was to specify that value as an int, since it’s just a default users can override. Or if they were to supply -e timesync_step_threshold=1.0 from the CLI it would become a string.
There are many ways in which a user tries to specify a value and it results in a string, such as {{ previsouly_a_float }} will become a string if done as a module argument to something like set_fact. Unless jinja2_native is enabled.
I think I’d need more evidence and context about how the role is being run, and if/how the user is specifying that value.
Regardless, the change is safe, and sane. It probably makes sense to cast them, especially if a caller was to specify that value as an int, since it’s just a default users can override. Or if they were to supply -e timesync_step_threshold=1.0 from the CLI it would become a string.
There are many ways in which a user tries to specify a value and it results in a string, such as {{ previsouly_a_float }} will become a string if done as a module argument to something like set_fact. Unless jinja2_native is enabled.
Which to me implies that, in template code (macros or otherwise), we should always cast anything which is a float or an int, because we can never be sure how the value was input.