summaryrefslogtreecommitdiffstats
path: root/lib/ansible/plugins/filter/flatten.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /lib/ansible/plugins/filter/flatten.yml
parentInitial commit. (diff)
downloadansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz
ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/plugins/filter/flatten.yml')
-rw-r--r--lib/ansible/plugins/filter/flatten.yml32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/ansible/plugins/filter/flatten.yml b/lib/ansible/plugins/filter/flatten.yml
new file mode 100644
index 0000000..b909c3d
--- /dev/null
+++ b/lib/ansible/plugins/filter/flatten.yml
@@ -0,0 +1,32 @@
+DOCUMENTATION:
+ name: flatten
+ version_added: "2.5"
+ short_description: flatten lists within a list
+ description:
+ - For a given list, take any elements that are lists and insert their elements into the parent list directly.
+ positional: _input, levels, skip_nulls
+ options:
+ _input:
+ description: First dictionary to combine.
+ type: dict
+ required: true
+ levels:
+ description: Number of recursive list depths to flatten.
+ type: int
+ skip_nulls:
+ description: Skip C(null)/C(None) elements when inserting into the top list.
+ type: bool
+ default: true
+
+EXAMPLES: |
+
+ # [1,2,3,4,5,6]
+ flat: "{{ [1 , 2, [3, [4, 5]], 6] | flatten }}"
+
+ # [1,2,3,[4,5],6]
+ flatone: "{{ [1, 2, [3, [4, 5]], 6] | flatten(1) }}"
+
+RETURN:
+ _value:
+ description: The flattened list.
+ type: list