Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3.11/site-packages/ansible/plugins/lookup/__pycache__/ |
Upload File : |
� ���c� � �n � d dl mZmZmZ eZdZdZdZd dl m Z mZ d dlm Z d dlmZ G d� d e� � Zd S )� )�absolute_import�division�print_functiona 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. a� - 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="{{ lookup('ansible.builtin.vars', 'variabl' + myvar)}}" ignore_errors: True vars: variablename: hello myvar: notename - name: find several related variables ansible.builtin.debug: msg="{{ lookup('ansible.builtin.vars', 'ansible_play_hosts', 'ansible_play_batch', 'ansible_play_hosts_all') }}" - 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 � � e Zd Zdd�ZdS )�LookupModuleNc � � |�|| j _ t | j di � � }| � ||�� � | � d� � }g }|D ]�}t |t � � s"t d|�dt |� � ��� � � || }nL# t $ r? |d |d | }n # t $ r t d|z � � �w xY wY nw xY w|� | j � |d � � � � � ��# t $ r |�|� |� � n� Y ��w xY w|S )N�_available_variables)�var_options�direct�defaultzInvalid setting identifier, "z" is not a string, its a �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�values �@/usr/lib/python3.11/site-packages/ansible/plugins/lookup/vars.py�runzLookupModule.runM s� � �� �09�D�M�-����(>��C�C�����Y�v��>�>�>��/�/�)�,�,����� � �D��d�L�1�1� v�"�l�cg�cg�cg�im�nr�is�is�is�#t�u�u�u� �f�"�4�L�E�E��� f� f� f�f� &�z� 2�6�:N�3O� P�QU� V����#� f� f� f�6�7]�`d�7d�e�e�e�f���� ��f���� � � �4�=�1�1�%�4�1�P�P�Q�Q�Q�Q��+� � � ��&��J�J�w�'�'�'�'�� (�'� ���� � sH �B�D� C"�$B?�>C"�?C�C"�D�!C"�"2D�#D;�:D;)N)�__name__� __module__�__qualname__r'