o n¾nh–ã@sPddlmZdZdZdZddlmZddlmZddl m Z Gdd „d e ƒZ d S) é)Ú 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@seZdZddd„ZdS)Ú LookupModuleNcKsDt|tƒs|g}g}|D]}t|tƒstdƒ‚| | |¡¡q |S)Nzwith_dict expects a dict)Ú isinstanceÚlistrrÚextendÚ_flatten_hash_to_list)ÚselfÚtermsÚ variablesÚkwargsÚresultsÚterm©rúF/usr/local/lib/python3.10/dist-packages/ansible/plugins/lookup/dict.pyÚrun?s  zLookupModule.run)N)Ú__name__Ú __module__Ú __qualname__rrrrrr=srN) Ú __future__rÚ DOCUMENTATIONÚEXAMPLESÚRETURNÚcollections.abcrÚansible.errorsrÚansible.plugins.lookuprrrrrrÚs