
    VhY
                    f    d dl mZ dZdZdZd dlmZ d dlmZm	Z	 d dl
mZ d dlmZ  G d	 d
e      Zy)    )annotationsaf  
    name: nested
    version_added: "1.1"
    short_description: composes a list with nested elements of other lists
    description:
        - Takes the input lists and returns a list with elements that are lists composed of the elements of the input lists
    options:
      _raw:
         description:
           - a set of lists
         required: True
as  
- 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' ]
zr
  _list:
    description:
      - A list composed of lists paring the elements of the input lists
    type: list
)UndefinedError)AnsibleErrorAnsibleUndefinedVariable)
LookupBase)listify_lookup_plugin_termsc                      e Zd Zd ZddZy)LookupModulec                    g }|D ],  }	 t        || j                  d      }|j	                  |       . |S # t        $ r}t        d|z        d }~ww xY w)NT)templarfail_on_undefinedz<One of the nested variables was undefined. The error was: %s)r   _templarr   r   append)selfterms	variablesresultsxintermediatees          M/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/lookup/nested.py_lookup_variableszLookupModule._lookup_variables:   sj     	)As:1dmmgkl NN<(	)  " s./mpq/qrrss   6	AAANc                z   | j                  ||      }|d d  }|j                          g }t        |      dk(  rt        d      |j	                         }t        |      dkD  r1| j                  ||j	                               }|}t        |      dkD  r1g }|D ]"  }|j                  | j                  |             $ |S )Nr   z<with_nested requires at least one element in the nested list)r   reverselenr   pop_combiner   _flatten)	r   r   r   kwargsmy_listresultresult2
new_resultr   s	            r   runzLookupModule.runD   s    &&ui8(w<1]^^'lQmmFGKKM:GF 'lQ 
 	0AdmmA./	0    )N)__name__
__module____qualname__r   r$    r%   r   r
   r
   8   s    r%   r
   N)
__future__r   DOCUMENTATIONEXAMPLESRETURNjinja2.exceptionsr   ansible.errorsr   r   ansible.plugins.lookupr   ansible.utils.listifyr   r
   r)   r%   r   <module>r2      s9    #.
 - A - =: r%   