You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* union documented incorrectly
The invalid documentation of union was fixed in ansible/ansible#82199 but didn't populate into this section of the docs.
* Apply suggestions from code review
Co-authored-by: Felix Fontein <[email protected]>
---------
Co-authored-by: Felix Fontein <[email protected]>
Copy file name to clipboardExpand all lines: docs/docsite/rst/playbook_guide/playbooks_filters.rst
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1167,7 +1167,7 @@ Preserve nulls in a list, by default flatten removes them. :
1167
1167
Selecting from sets or lists (set theory)
1168
1168
=========================================
1169
1169
1170
-
You can select or combine items from sets or lists.
1170
+
You can select or combine items from sets or lists. Note, multisets are currently not supported and all of the following filters imply uniqueness. That means that duplicate elements are removed from the result.
1171
1171
1172
1172
.. versionadded:: 1.4
1173
1173
@@ -1179,14 +1179,14 @@ To get a unique set from a list:
1179
1179
{{ list1 | unique }}
1180
1180
# => [1, 2, 5, 3, 4, 10]
1181
1181
1182
-
To get a union of two lists:
1182
+
To get a union (with duplicate elements removed) of two lists:
1183
1183
1184
1184
.. code-block:: jinja
1185
1185
1186
1186
# list1: [1, 2, 5, 1, 3, 4, 10]
1187
1187
# list2: [1, 2, 3, 4, 5, 11, 99]
1188
1188
{{ list1 | union(list2) }}
1189
-
# => [1, 2, 5, 1, 3, 4, 10, 11, 99]
1189
+
# => [1, 2, 3, 4, 5, 99, 10, 11]
1190
1190
1191
1191
To get the intersection of 2 lists (unique list of all items in both):
1192
1192
@@ -1195,7 +1195,7 @@ To get the intersection of 2 lists (unique list of all items in both):
1195
1195
# list1: [1, 2, 5, 3, 4, 10]
1196
1196
# list2: [1, 2, 3, 4, 5, 11, 99]
1197
1197
{{ list1 | intersect(list2) }}
1198
-
# => [1, 2, 5, 3, 4]
1198
+
# => [1, 2, 3, 4, 5]
1199
1199
1200
1200
To get the difference of 2 lists (items in 1 that don't exist in 2):
1201
1201
@@ -1213,7 +1213,7 @@ To get the symmetric difference of 2 lists (items exclusive to each list):
0 commit comments