mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
d5e4f37ca0
commit
f6ecdf0b87
3 changed files with 19 additions and 1 deletions
2
changelogs/fragments/unsafe-set-wrap.yaml
Normal file
2
changelogs/fragments/unsafe-set-wrap.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- unsafe - Add special casing to sets, to support wrapping elements of sets correctly in Python 3 (https://github.com/ansible/ansible/issues/47372)
|
|
@ -95,11 +95,17 @@ def _wrap_list(v):
|
|||
return v
|
||||
|
||||
|
||||
def _wrap_set(v):
|
||||
return set(item if item is None else wrap_var(item) for item in v)
|
||||
|
||||
|
||||
def wrap_var(v):
|
||||
if isinstance(v, Mapping):
|
||||
v = _wrap_dict(v)
|
||||
elif isinstance(v, (MutableSequence, Set)):
|
||||
elif isinstance(v, MutableSequence):
|
||||
v = _wrap_list(v)
|
||||
elif isinstance(v, Set):
|
||||
v = _wrap_set(v)
|
||||
elif v is not None and not isinstance(v, AnsibleUnsafe):
|
||||
v = UnsafeProxy(v)
|
||||
return v
|
||||
|
|
|
@ -258,3 +258,13 @@
|
|||
loop: []
|
||||
register: literal_empty_list
|
||||
failed_when: literal_empty_list is not skipped
|
||||
|
||||
# https://github.com/ansible/ansible/issues/47372
|
||||
- name: Loop unsafe list
|
||||
debug:
|
||||
var: item
|
||||
with_items: "{{ things|list|unique }}"
|
||||
vars:
|
||||
things:
|
||||
- !unsafe foo
|
||||
- !unsafe bar
|
||||
|
|
Loading…
Reference in a new issue