File: //lib/python3.9/site-packages/ansible/plugins/lookup/__pycache__/varnames.cpython-39.pyc
a
�)g> � @ sp d dl mZmZmZ eZdZdZdZd dl Z d dl
mZ d dlm
Z
d dlmZ d d lmZ G d
d� de�ZdS )� )�absolute_import�division�print_functionaU
name: varnames
author: Ansible Core Team
version_added: "2.8"
short_description: Lookup matching variable names
description:
- Retrieves a list of matching Ansible variable names.
options:
_terms:
description: List of Python regex patterns to search for in variable names.
required: True
am
- name: List variables that start with qz_
ansible.builtin.debug: msg="{{ lookup('ansible.builtin.varnames', '^qz_.+')}}"
vars:
qz_1: hello
qz_2: world
qa_1: "I won't show"
qz_: "I won't show either"
- name: Show all variables
ansible.builtin.debug: msg="{{ lookup('ansible.builtin.varnames', '.+')}}"
- name: Show variables with 'hosts' in their names
ansible.builtin.debug: msg="{{ lookup('ansible.builtin.varnames', 'hosts')}}"
- name: Find several related variables that end specific way
ansible.builtin.debug: msg="{{ lookup('ansible.builtin.varnames', '.+_zone$', '.+_location$') }}"
zQ
_value:
description:
- List of the variable names requested.
type: list
N)�AnsibleError)� to_native)�string_types)�
LookupBasec @ s e Zd Zddd�ZdS )�LookupModuleNc
K s� |d u rt d��| j||d� g }t|�� �}|D ]�}t|t�sTt d|t|�f ��zt�|�}W n8 t y� } z t d|t
|�f ��W Y d }~n
d }~0 0 |D ]} |�| �r�|�| � q�q2|S )Nz No variables available to search)Zvar_optionsZdirectz<Invalid setting identifier, "%s" is not a string, it is a %sz,Unable to use "%s" as a search parameter: %s)
r Zset_options�list�keys�
isinstancer �type�re�compile� Exceptionr �search�append)
�selfZtermsZ variables�kwargs�retZvariable_namesZterm�name�eZvarname� r �C/usr/lib/python3.9/site-packages/ansible/plugins/lookup/varnames.py�run8 s
*
zLookupModule.run)N)�__name__�
__module__�__qualname__r r r r r r 6 s r )Z
__future__r r r r
Z
__metaclass__Z
DOCUMENTATIONZEXAMPLESZRETURNr Zansible.errorsr Zansible.module_utils._textr Zansible.module_utils.sixr Zansible.plugins.lookupr r r r r r �<module> s