관리-도구
편집 파일: dict.cpython-39.opt-1.pyc
a �)g� � @ s\ d dl mZmZmZ eZdZdZdZd dl m Z d dlmZ d dl mZ G dd � 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 @ s e Zd Zddd�ZdS )�LookupModuleNc K sD t |t�s|g}g }|D ]&}t |t�s.td��|�| �|�� q|S )Nzwith_dict expects a dict)� isinstance�listr r �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__r r r r r r >