
    Vh                    V    d dl mZ dZdZdZd dlmZ d dlmZ d dl	m
Z
  G d d	e
      Zy
)    )annotationsa  
    name: dict
    version_added: "1.5"
    short_description: returns key/value pair items from dictionaries
    description:
        - Takes dictionaries as input and returns a list with each item in the list being a dictionary with 'key' and 'value' as
          keys to the previous dictionary's structure.
    options:
        _terms:
            description:
                - A list of dictionaries
            required: True
a  
vars:
  users:
    alice:
      name: Alice Appleworth
      telephone: 123-456-7890
    bob:
      name: Bob Bananarama
      telephone: 987-654-3210
tasks:
  # with predefined vars
  - name: Print phone records
    ansible.builtin.debug:
      msg: "User {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})"
    loop: "{{ lookup('ansible.builtin.dict', users) }}"
  # with inline dictionary
  - name: show dictionary
    ansible.builtin.debug:
      msg: "{{item.key}}: {{item.value}}"
    with_dict: {a: 1, b: 2, c: 3}
  # Items from loop can be used in when: statements
  - name: set_fact when alice in key
    ansible.builtin.set_fact:
      alice_exists: true
    loop: "{{ lookup('ansible.builtin.dict', users) }}"
    when: "'alice' in item.key"
zc
  _list:
    description:
      - list of composed dictionaries with key and value
    type: list
)Mapping)AnsibleError)
LookupBasec                      e Zd ZddZy)LookupModuleNc                    t        |t              s|g}g }|D ]=  }t        |t              st        d      |j	                  | j                  |             ? |S )Nzwith_dict expects a dict)
isinstancelistr   r   extend_flatten_hash_to_list)selfterms	variableskwargsresultsterms         K/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/lookup/dict.pyrunzLookupModule.run?   s]     %&GE 	=DdG,"#=>>NN455d;<	=     )N)__name__
__module____qualname__r    r   r   r   r   =   s    r   r   N)
__future__r   DOCUMENTATIONEXAMPLESRETURNcollections.abcr   ansible.errorsr   ansible.plugins.lookupr   r   r   r   r   <module>r"      s6    #8
 $ ' -: r   