a ì)gÊã@s\ddlmZmZmZeZdZdZdZddl m Z ddl m Z ddl mZGdd „d eƒZd S) é)Úabsolute_importÚdivisionÚprint_functiona² 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" zb _list: description: - list of composed dictonaries with key and value type: list )ÚMapping)Ú AnsibleError)Ú LookupBasec@seZdZddd„ZdS)Ú LookupModuleNcKsDt|tƒs|g}g}|D]&}t|tƒs.tdƒ‚| | |¡¡q|S)Nzwith_dict expects a dict)Ú isinstanceÚlistrrÚextendZ_flatten_hash_to_list)ÚselfZtermsZ variablesÚkwargsÚresultsZterm©rú?/usr/lib/python3.9/site-packages/ansible/plugins/lookup/dict.pyÚrun@s  zLookupModule.run)N)Ú__name__Ú __module__Ú __qualname__rrrrrr>srN)Z __future__rrrÚtypeZ __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNÚcollections.abcrZansible.errorsrZansible.plugins.lookuprrrrrrÚs