Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
local
/
lib
/
python3.10
/
dist-packages
/
ansible
/
plugins
/
lookup
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: vars.cpython-310.pyc
o O�hX � @ sT d dl mZ dZdZdZd dlmZmZ d dlm Z d dl mZ G dd � d e�Zd S )� )�annotationsam name: vars author: Ansible Core Team version_added: "2.5" short_description: Lookup templated value of variables description: - 'Retrieves the value of an Ansible variable. Note: Only returns top level variable names.' options: _terms: description: The variable names to look up. required: True default: description: - What to return if a variable is undefined. - If no default is set, it will result in an error if any of the variables is undefined. seealso: - plugin_type: lookup plugin: ansible.builtin.varnames aZ - name: Show value of 'variablename' ansible.builtin.debug: msg="{{ lookup('ansible.builtin.vars', 'variabl' + myvar) }}" vars: variablename: hello myvar: ename - name: Show default empty since i dont have 'variablnotename' ansible.builtin.debug: msg="{{ lookup('ansible.builtin.vars', 'variabl' + myvar, default='') }}" vars: variablename: hello myvar: notename - name: Produce an error since i dont have 'variablnotename' ansible.builtin.debug: msg="{{ q('vars', 'variabl' + myvar) }}" ignore_errors: True vars: variablename: hello myvar: notename - name: find several related variables ansible.builtin.debug: msg="{{ query('ansible.builtin.vars', 'ansible_play_hosts', 'ansible_play_batch', 'ansible_play_hosts_all') }}" - name: show values from variables found via varnames (note "*" is used to dereference the list to a 'list of arguments') debug: msg="{{ q('vars', *q('varnames', 'ansible_play_.+')) }}" - name: Access nested variables ansible.builtin.debug: msg="{{ lookup('ansible.builtin.vars', 'variabl' + myvar).sub_var }}" ignore_errors: True vars: variablename: sub_var: 12 myvar: ename - name: alternate way to find some 'prefixed vars' in loop ansible.builtin.debug: msg="{{ lookup('ansible.builtin.vars', 'ansible_play_' + item) }}" loop: - hosts - batch - hosts_all z] _value: description: - value of the variables requested. type: list elements: raw )�AnsibleError�AnsibleUndefinedVariable)�string_types)� LookupBasec @ s e Zd Zddd�ZdS )�LookupModuleNc K s� |d ur|| j _t| j di �}| j||d� | �d�}g }|D ]\}t|t�s0td|t|�f ��z7z|| }W n# t yZ z|d |d | }W n t yW t d| ��w Y nw |�| j j|dd �� W q t y{ |d urx|�|� n� Y qw |S ) N�_available_variables)�var_options�direct�defaultz:Invalid setting identifier, "%s" is not a string, its a %s�hostvars�inventory_hostnamez$No variable found with this name: %sT)�fail_on_undefined) �_templar�available_variables�getattr�set_options� get_option� isinstancer r �type�KeyErrorr �append�template) �self�terms� variables�kwargs�myvarsr �ret�term�value� r! �F/usr/local/lib/python3.10/dist-packages/ansible/plugins/lookup/vars.py�runS s8 �����zLookupModule.run)N)�__name__� __module__�__qualname__r# r! r! r! r"