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

Note

This module is part of ansible-core and included in all Ansible installations. In most cases, you can use the short module name nested even without specifying the collections: keyword. However, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module 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 Choices/Defaults Configuration Comments
_raw
string / required
a set of lists

Examples

- name: give users access to multiple databases
  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
  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 Returned Description
_list
list / elements=string
success
A list composed of lists paring the elements of the input lists