W3cubDocs

/Ansible 2.10

community.general.flattened – return single list completely flattened

Note

This plugin is part of the community.general collection.

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.flattened.

Synopsis

  • given one or more lists, this lookup will flatten any list elements found recursively until only 1 list is left.

Parameters

Parameter Choices/Defaults Configuration Comments
_terms
string / required
lists to flatten

Notes

Note

  • unlike ‘items’ which only flattens 1 level, this plugin will continue to flatten until it cannot find lists anymore.
  • aka highlander plugin, there can only be one (list).

Examples

- name: "'unnest' all elements into single list"
  ansible.builtin.debug:
    msg: "all in one list {{lookup('community.general.flattened', [1,2,3,[5,6]], [a,b,c], [[5,6,1,3], [34,a,b,c]])}}"

Return Values

Common return values are documented here, the following are the fields unique to this lookup:

Key Returned Description
_raw
list / elements=string
success
flattened list



Authors

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/community/general/flattened_lookup.html