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 zip_longest. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.zip_longest for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same filter plugin name.
fillvalue. Iteration continues until the longest iterable is exhausted.This describes the input of the filter, the value before | ansible.builtin.zip_longest.
Parameter | Comments |
|---|---|
Input list / elements=any / required | Original list. |
This describes positional parameters of the filter. These are the values positional1, positional2 and so on in the following example: input | ansible.builtin.zip_longest(positional1, positional2, ...)
Parameter | Comments |
|---|---|
_additional_lists list / elements=any / required | Additional list(s). |
This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | ansible.builtin.zip_longest(key1=value1, key2=value2, ...)
Parameter | Comments |
|---|---|
fillvalue any | Filler value to add to output when one of the lists does not contain enough elements to match the others. |
Note
input | ansible.builtin.zip_longest(positional1, positional2, key1=value1, key2=value2)
itertools.zip_longest function# X_fill => [[1, "a", 21], [2, "b", 22], [3, "c", 23], ["X", "d", "X"], ["X", "e", "X"], ["X", "f", "X"]]
X_fill: "{{ [1,2,3] | zip_longest(['a','b','c','d','e','f'], [21, 22, 23], fillvalue='X') }}"
Key | Description |
|---|---|
Return value list / elements=list | List of lists made of elements matching the positions of 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/zip_longest_filter.html