ansible.builtin.unique filter – set of unique items of a list


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 even without specifying the collections: keyword. However, we recommend you use the FQCN for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same filter plugin name.

New in Ansible 1.4


  • Creates a list of unique elements (a set) from the provided input list.


This describes the input of the filter, the value before | ansible.builtin.unique.




list / elements=string / required

A list.

See Also

See also

ansible.builtin.difference filter plugin

The official documentation on the ansible.builtin.difference filter plugin.

ansible.builtin.intersect filter plugin

The official documentation on the ansible.builtin.intersect filter plugin.

ansible.builtin.symmetric_difference filter plugin

The official documentation on the ansible.builtin.symmetric_difference filter plugin.

ansible.builtin.union filter plugin

The official documentation on the ansible.builtin.union filter plugin.


# 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



Return value

list / elements=string

A list with unique elements, also known as a set.

Returned: success


  • Brian Coca (@bcoca)


Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.