Skip to content

combinations

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version historical.

Synopsis

  • Create a list of combinations of sets from the elements of a list.

Parameters

Parameter Defaults / Choices Comments
_input
list
required
Elements to combine.
set_size
int
required
The size of the set for each combination.

Examples

# combos_of_two => [ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 1, 5 ], [ 2, 3 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ], [ 4, 5 ] ]
combos_of_two: "{{ [1,2,3,4,5] | combinations(2) }}"

Return Values

Key Data Type Description Returned
_value list List of combination sets resulting from the supplied elements and set size.