File tree 5 files changed +11
-19
lines changed
integration/targets/jinja2_native_types
5 files changed +11
-19
lines changed Original file line number Diff line number Diff line change 13
13
from jinja2 .runtime import StrictUndefined
14
14
15
15
from ansible .module_utils ._text import to_text
16
+ from ansible .module_utils .common .text .converters import container_to_text
17
+ from ansible .module_utils .six import PY2
16
18
from ansible .parsing .yaml .objects import AnsibleVaultEncryptedUnicode
17
19
18
20
@@ -48,10 +50,6 @@ def ansible_native_concat(nodes):
48
50
# See https://github.com/ansible/ansible/issues/52158
49
51
# We do that only here because it is taken care of by to_text() in the else block below already.
50
52
str (out )
51
-
52
- # short circuit literal_eval when possible
53
- if not isinstance (out , list ):
54
- return out
55
53
else :
56
54
if isinstance (nodes , types .GeneratorType ):
57
55
nodes = chain (head , nodes )
@@ -60,6 +58,10 @@ def ansible_native_concat(nodes):
60
58
out = u'' .join ([to_text (v ) for v in nodes ])
61
59
62
60
try :
63
- return literal_eval (out )
61
+ out = literal_eval (out )
62
+ if PY2 :
63
+ # ensure bytes are not returned back into Ansible from templating
64
+ out = container_to_text (out )
65
+ return out
64
66
except (ValueError , SyntaxError , MemoryError ):
65
67
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 @@ -286,8 +286,6 @@ test/integration/targets/incidental_win_dsc/files/xTestDsc/1.0.1/DSCResources/AN
286
286
test/integration/targets/incidental_win_dsc/files/xTestDsc/1.0.1/xTestDsc.psd1 pslint!skip
287
287
test/integration/targets/incidental_win_ping/library/win_ping_syntax_error.ps1 pslint!skip
288
288
test/integration/targets/incidental_win_reboot/templates/post_reboot.ps1 pslint!skip
289
- test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py future-import-boilerplate
290
- test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py metaclass-boilerplate
291
289
test/integration/targets/lookup_ini/lookup-8859-15.ini no-smart-quotes
292
290
test/integration/targets/module_precedence/lib_with_extension/ping.py future-import-boilerplate
293
291
test/integration/targets/module_precedence/lib_with_extension/ping.py metaclass-boilerplate
You can’t perform that action at this time.
0 commit comments