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
. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.nested
for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same lookup plugin name.
Synopsis
- Takes the input lists and returns a list with elements that are lists composed of the elements of the input lists
Keyword parameters
This describes keyword parameters of the lookup. These are the values key1=value1
, key2=value2
and so on in the following examples: lookup('ansible.builtin.nested', key1=value1, key2=value2, ...)
and query('ansible.builtin.nested', key1=value1, key2=value2, ...)
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 Value
Key | Description |
---|---|
Return value 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.
Collection links
© 2012–2018 Michael DeHaan
© 2018–2024 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/nested_lookup.html