File tree 5 files changed +12
-19
lines changed
integration/targets/jinja2_native_types
5 files changed +12
-19
lines changed Original file line number Diff line number Diff line change 13
13
from jinja2 ._compat import text_type
14
14
15
15
from jinja2 .runtime import StrictUndefined
16
+
17
+ from ansible .module_utils .common .text .converters import container_to_text
18
+ from ansible .module_utils .six import PY2
16
19
from ansible .parsing .yaml .objects import AnsibleVaultEncryptedUnicode
17
20
18
21
@@ -48,10 +51,6 @@ def ansible_native_concat(nodes):
48
51
# See https://github.com/ansible/ansible/issues/52158
49
52
# We do that only here because it is taken care of by text_type() in the else block below already.
50
53
str (out )
51
-
52
- # short circuit literal_eval when possible
53
- if not isinstance (out , list ):
54
- return out
55
54
else :
56
55
if isinstance (nodes , types .GeneratorType ):
57
56
nodes = chain (head , nodes )
@@ -60,6 +59,10 @@ def ansible_native_concat(nodes):
60
59
out = u'' .join ([text_type (v ) for v in nodes ])
61
60
62
61
try :
63
- return literal_eval (out )
62
+ out = literal_eval (out )
63
+ if PY2 :
64
+ # ensure bytes are not returned back into Ansible from templating
65
+ out = container_to_text (out )
66
+ return out
64
67
except (ValueError , SyntaxError , MemoryError ):
65
68
return out
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
- name : cast things to other things
2
2
set_fact :
3
- int_to_str : " {{ i_two|to_text }}"
3
+ int_to_str : " ' {{ i_two }}' "
4
4
str_to_int : " {{ s_two|int }}"
5
- dict_to_str : " {{ dict_one|to_text }}"
6
- list_to_str : " {{ list_one|to_text }}"
5
+ dict_to_str : " ' {{ dict_one }}' "
6
+ list_to_str : " ' {{ list_one }}' "
7
7
int_to_bool : " {{ i_one|bool }}"
8
8
str_true_to_bool : " {{ s_true|bool }}"
9
9
str_false_to_bool : " {{ s_false|bool }}"
Original file line number Diff line number Diff line change 18
18
19
19
- name : concatenate int and string
20
20
set_fact :
21
- string_sum : " {{ [( i_one|to_text) , s_two]|join('') }}"
21
+ string_sum : " ' {{ [i_one, s_two]|join('') }}' "
22
22
23
23
- assert :
24
24
that :
Original file line number Diff line number Diff line change @@ -5984,8 +5984,6 @@ test/integration/targets/inventory_kubevirt_conformance/inventory_diff.py future
5984
5984
test/integration/targets/inventory_kubevirt_conformance/inventory_diff.py metaclass-boilerplate
5985
5985
test/integration/targets/inventory_kubevirt_conformance/server.py future-import-boilerplate
5986
5986
test/integration/targets/inventory_kubevirt_conformance/server.py metaclass-boilerplate
5987
- test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py future-import-boilerplate
5988
- test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py metaclass-boilerplate
5989
5987
test/integration/targets/lambda_policy/files/mini_http_lambda.py future-import-boilerplate
5990
5988
test/integration/targets/lambda_policy/files/mini_http_lambda.py metaclass-boilerplate
5991
5989
test/integration/targets/lookup_properties/lookup-8859-15.ini no-smart-quotes
You can’t perform that action at this time.
0 commit comments