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 product. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.product for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same filter plugin name.
listA and listB is the same as looping over listA | product(listB).This describes the input of the filter, the value before | ansible.builtin.product.
Parameter | Comments |
|---|---|
Input list / elements=string / required | First list. |
This describes positional parameters of the filter. These are the values positional1, positional2 and so on in the following example: input | ansible.builtin.product(positional1, positional2, ...)
Parameter | Comments |
|---|---|
_additional_lists list / elements=string | Additional list for the product. |
repeat integer | Number of times to repeat the product against itself. Default: |
Note
itertools.product
# product => [ [ 1, "a" ], [ 1, "b" ], [ 1, "c" ], [ 2, "a" ], [ 2, "b" ], [ 2, "c" ], [ 3, "a" ], [ 3, "b" ], [ 3, "c" ], [ 4, "a" ], [ 4, "b" ], [ 4, "c" ], [ 5, "a" ], [ 5, "b" ], [ 5, "c" ] ]
product: "{{ [1,2,3,4,5] | product(['a', 'b', 'c']) }}"
# repeat_original => [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]
repeat_original: "{{ [1,2] | product(repeat=2) }}"
# repeat_product => [ [ 1, "a", 1, "a" ], [ 1, "a", 1, "b" ], [ 1, "a", 2, "a" ], [ 1, "a", 2, "b" ], [ 1, "b", 1, "a" ], [ 1, "b", 1, "b" ], [ 1, "b", 2, "a" ], [ 1, "b", 2, "b" ], [ 2, "a", 1, "a" ], [ 2, "a", 1, "b" ], [ 2, "a", 2, "a" ], [ 2, "a", 2, "b" ], [ 2, "b", 1, "a" ], [ 2, "b", 1, "b" ], [ 2, "b", 2, "a" ], [ 2, "b", 2, "b" ] ]
repeat_product: "{{ [1,2] | product(['a', 'b'], repeat=2) }}"
# domains => [ 'example.com', 'ansible.com', 'redhat.com' ]
domains: "{{ [ 'example', 'ansible', 'redhat'] | product(['com']) | map('join', '.') }}"
Key | Description |
|---|---|
Return value list / elements=list | List of lists of combined elements from the input lists. Returned: success |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/product_filter.html