jinja2_native behavior

Is this expected behavior?

% ANSIBLE_JINJA2_NATIVE=true ansible -i localhost, localhost -m debug -a var=this -e “this=‘None’”

localhost | SUCCESS => {

“this”: null

}

% ANSIBLE_JINJA2_NATIVE=false ansible -i localhost, localhost -m debug -a var=this -e “this=‘None’”

localhost | SUCCESS => {

“this”: “None”

}

Just making sure that jinja2_native=True should convert a string value of “None” to value null when evaluated.

Walter

As of now, yes. Non-native jinja only runs things that look like a list, dict, set, bool through ast.literal_eval, leaving everything else as a str. Native sends everything through ast.literal_eval.

If instead you used -e "this='[None]'" you would notice that it becomes [null] on both, due to it appearing as a list.

However, this may be changing in 2.17 or 2.18, as changes are being made to how native jinja works, by making it native through the whole jinja process. As such, it would leave the string ‘None’ as a string. Also, non-native will go away at that point, since it will more closely act like most expect.