ansible.builtin.nested lookup – composes a list with nested elements of other lists

Note

This lookup plugin is part of ansible-core and included in all Ansible installations. In most cases, you can use the short plugin name nested 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 lookup plugin name.

New in version 1.1: of ansible.builtin

Synopsis

  • Takes the input lists and returns a list with elements that are lists composed of the elements of the input lists

Parameters

Parameter

Comments

_raw

string / required

a set of lists

Examples

- name: give users access to multiple databases
  community.mysql.mysql_user:
    name: "{{ item[0] }}"
    priv: "{{ item[1] }}.*:ALL"
    append_privs: yes
    password: "foo"
  with_nested:
    - [ 'alice', 'bob' ]
    - [ 'clientdb', 'employeedb', 'providerdb' ]
# As with the case of 'with_items' above, you can use previously defined variables.:

- name: here, 'users' contains the above list of employees
  community.mysql.mysql_user:
    name: "{{ item[0] }}"
    priv: "{{ item[1] }}.*:ALL"
    append_privs: yes
    password: "foo"
  with_nested:
    - "{{ users }}"
    - [ 'clientdb', 'employeedb', 'providerdb' ]

Return Values

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

Key

Description

_list

list / elements=string

A list composed of lists paring the elements of the input lists

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.