ansible.builtin.unique filter – set of unique items of a list
Note
This filter plugin is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
plugin name
unique
.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.unique
for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same filter plugin name.
Synopsis
Creates a list of unique elements (a set) from the provided input list.
Input
This describes the input of the filter, the value before | ansible.builtin.unique
.
Parameter |
Comments |
---|---|
A list. |
See Also
See also
- ansible.builtin.difference filter plugin
the difference of one list from another.
- ansible.builtin.intersect filter plugin
intersection of lists.
- ansible.builtin.symmetric_difference filter plugin
different items from two lists.
- ansible.builtin.union filter plugin
union of lists.
Examples
# return only the unique elements of list1
# list1: [1, 2, 5, 1, 3, 4, 10]
{{ list1 | unique }}
# => [1, 2, 5, 3, 4, 10]
Return Value
Key |
Description |
---|---|
A list with unique elements, also known as a set. Returned: success |