added flatten filter (#33102)

* added flatten filter
This commit is contained in:
Brian Coca
2017-12-15 14:40:02 -05:00
committed by GitHub
parent c2ac9d0831
commit 2b7799f817
3 changed files with 52 additions and 0 deletions

View File

@@ -168,3 +168,20 @@
that:
- _bad_urlsplit_filter is failed
- "'unknown URL component' in _bad_urlsplit_filter.msg"
- name: Flatten tests
block:
- name: use flatten
set_fact:
flat_full: '{{orig_list|flatten}}'
flat_one: '{{orig_list|flatten(levels=1)}}'
flat_two: '{{orig_list|flatten(levels=2)}}'
- name: Verify flatten filter works as expected
assert:
that:
- flat_full == [1, 2, 3, 4, 5, 6, 7]
- flat_one == [1, 2, 3, [4, [5]], 6, 7]
- flat_two == [1, 2, 3, 4, [5], 6, 7]
vars:
orig_list: [1, 2, [3, [4, [5]], 6], 7]