ansible.builtin.permutations filter – permutations from the elements 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
permutations
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.
Synopsis
Create a list of the permutations of lists from the elements of a list.
Unlike combinations, in permutations order is significant.
Input
This describes the input of the filter, the value before | ansible.builtin.permutations
.
Parameter |
Comments |
---|---|
Elements to base the permutations on. |
Positional parameters
This describes positional parameters of the filter. These are the values positional1
, positional2
and so on in the following
example: input | ansible.builtin.permutations(positional1, positional2, ...)
Parameter |
Comments |
---|---|
The size of the list for each permutation. |
Examples
# ptrs_of_two => [ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 1, 5 ], [ 2, 1 ], [ 2, 3 ], [ 2, 4 ], [ 2, 5 ], [ 3, 1 ], [ 3, 2 ], [ 3, 4 ], [ 3, 5 ], [ 4, 1 ], [ 4, 2 ], [ 4, 3 ], [ 4, 5 ], [ 5, 1 ], [ 5, 2 ], [ 5, 3 ], [ 5, 4 ] ]
prts_of_two: "{{ [1,2,3,4,5] | permutations(2) }}"
Return Value
Key |
Description |
---|---|
List of permutations lists resulting from the supplied elements and list size. Returned: success |
Hint
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.