HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible/vars/__pycache__/manager.cpython-39.pyc
a

�)gR��@spddlmZmZmZeZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZddlmZddlmZmZmZmZmZmZdd	lmZdd
lmZm Z ddl!m"Z"ddl#m$Z$m%Z%dd
l&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1m2Z2m3Z3ddl4m5Z5ddl6m7Z7m8Z8ddl9m:Z:m;Z;e-�Z<dd�Z=Gdd�d�Z>Gdd�de�Z?dS)�)�absolute_import�division�print_functionN)�defaultdict)�Mapping�MutableMapping�Sequence)�sha1)�UndefinedError)�	constants)�AnsibleError�AnsibleParserError�AnsibleUndefinedVariable�AnsibleFileNotFound�AnsibleAssertionError�AnsibleTemplateError)�Host)�sort_groups�get_group_vars)�to_text)�	text_type�string_types)�
lookup_loader)�	FactCache)�Templar)�Display)�listify_lookup_plugin_terms)�combine_vars�load_extra_vars�load_options_vars)�wrap_var)�namespace_facts�clean_facts)�get_vars_from_inventory_sources�get_vars_from_pathcCsN|durdSt|t�s|g}n|}|D]"}t|t�s&td|t|�f��q&|S)z�
    Ensures that vars contained in the parameter passed in are
    returned as a list of dictionaries, to ensure for instance
    that vars loaded from a file conform to an expected state.
    Nzevariable files must contain either a dictionary of variables, or a list of dictionaries. Got: %s (%s))�
isinstance�listrr�type)�a�data�item�r+�8/usr/lib/python3.9/site-packages/ansible/vars/manager.py�preprocess_vars2s

r-c	@s�eZdZegd��Zddd�Zdd�Zdd�Zed	d
��Z	dd�Z
ddd�Zddd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �VariableManager)Zplugins_by_group�groups_plugins_play�groups_plugins_inventory�groups_inventory�all_plugins_play�all_plugins_inventory�
all_inventoryNc
Cs�tt�|_tt�|_tt�|_tt�|_tt�|_||_||_d|_	dt
t�d���
�|_t|�|_|j�dd�}t|dup�|�|_t|jd�|_zt�|_Wn8ty�}z t�t|��i|_WYd}~n
d}~00dS)N�__omit_place_holder__%s�@�basedirF��loader)r�dict�_nonpersistent_fact_cache�_vars_cache�_extra_vars�_host_vars_files�_group_vars_files�
_inventory�_loader�	_hostvarsr	�os�urandom�	hexdigest�_omit_tokenr�
_options_vars�get�bool�safe_basedirrr�_fact_cacher�display�warningr)�selfr9�	inventory�version_infor7�er+r+r,�__init__Ls$





zVariableManager.__init__cCs4t|j|j|j|j|j|j|j|j|j	|j
d�
}|S)N)
�
fact_cache�
np_fact_cache�
vars_cache�
extra_vars�host_vars_files�group_vars_files�
omit_token�options_varsrOrJ)r:rKr;r<r=r>r?rFrGr@rJ�rNr)r+r+r,�__getstate__js�zVariableManager.__getstate__cCs�|�dtt��|_|�dtt��|_|�dtt��|_|�dt��|_|�dtt��|_|�dtt��|_|�ddt	t
�d	�����|_
|�d
d�|_|�dt��|_|�dd
�|_d|_d|_dS)NrSrTrUrVrWrXrYr5r6rOrZrJF)rHrr:rKr;r<r=r>r?r	rCrDrErFr@rGrJrArBr[r+r+r,�__setstate__ys zVariableManager.__setstate__cCs|jS�N)r=�rNr+r+r,rV�szVariableManager.extra_varscCs
||_dSr^)r@)rNrOr+r+r,�
set_inventory�szVariableManager.set_inventoryT�taskc
"
s<t�d�t�}
�j|||||||d�}i��fdd��g��jrN�j��g�|rv|��D]}�|
|��d|j	�}
qZ|r�t
jdkr�|���n2t
jdvr�|��dg�nt
jd	kr�t
d
t
j��|jdur�|s�|jt
jvr��|
|jj|��d�d|jj	�}
|�r��jj�d��td
d�|��D����fdd�}
��fdd������fdd���fdd�}��fdd�}��fdd�}�fdd�}��fdd�}��fdd �}����fd!d"�}t
jD]N}|�jv�r�t�d#||j	f��|
t�|�d$|�}
nt�d%|��q��|
|��d&|�}
�|
�|g�d'|�}
�|
�|g�d(|�}
z^t�j�|j	i��}|
t|�O}
t
j�r��|
tt |��d)�}
n�|
td*|�d*i�i�d)�}
Wnt!�y�Yn0|�r�|
|��d+�}
|�"�}�z�|D�]�}t#|
�j$�}t#||�}t%�j|d,�}|}t&|t'��s$|g}z�|D]�}|�(|�}t&|t)��sPt
d-|��zd|��}�j�*|d.|�}}t+�jj,|d/d0d1��} | du�r�| D]}!�|
|!d2|�}
�q�W�qWn.t-�y�Y�q*Ynt.�y��Yn0�q*|�r|�rt-d3|��Wnlt/t0f�yn|du�rV�j�|j	t���d4��rV|du�rVt0d5||d6��nt�1d7|�Y�q�Yn0t�1d8|��q�Wn(t2�y�t.d9|t3|�f��Yn0t
j4�s�|��D] }�|
|jd0d:�d;|j	�}
�q�|�r"|j�r�|
|jj|��d0d:�d;|jj	�}
�|
|��d<�}
|�r^�|
�j5�|�6�t��d=�}
�|
�j7�|j	t��d>�}
|�r�|j�r��|
|j�8|���d?|jj	�}
�|
|�9�d@�}
�|
�j$dA�}
�|
|dB�}
|�r�|j:|
dC<|�s�|�r�|
�;�|
d.<|�r|�r|j<du�r|�r��=|||
�\|
dD<|
dE<t�dF�t
j>�r4t?�@|
��S|
SdS)Gan
        Returns the variables, with optional "context" given via the parameters
        for the play, host, and task (which could possibly result in different
        sets of variables being returned due to the additional context).

        The order of precedence is:
        - play->roles->get_default_vars (if there is a play context)
        - group_vars_files[host] (if there is a host context)
        - host_vars_files[host] (if there is a host context)
        - host->get_vars (if there is a host context)
        - fact_cache[host] (if there is a host context)
        - play vars (if there is a play context)
        - play vars_files (if there's no host context, ignore
          file names that cannot be templated)
        - task->get_vars (if there is a task context)
        - vars_cache[host] (if there is a host context)
        - extra vars

        ``_hosts`` and ``_hosts_all`` should be considered private args, with only internal trusted callers relying
        on the functionality they provide. These arguments may be removed at a later date without a deprecation
        period and without warning.
        zin VariableManager get_vars())�play�hostra�include_hostvars�include_delegate_to�_hosts�
_hosts_allcs"tjr|D]}|�|<q
t||�S)z�
            Wrapper function to update var sources dict and call combine_vars()

            See notes in the VarsWithSources docstring for caveats and limitations of the source tracking
            )�C�
DEFAULT_DEBUGr)r)Znew_data�source�key)�
_vars_sourcesr+r,�_combine_and_track�s
z4VariableManager.get_vars.<locals>._combine_and_trackzrole '%s' defaults�all)Zbottom�playbook_dirr�topzUnknown playbook vars logic: %sN)Z	dep_chaincSsg|]}|jdvr|�qS))rn��name)�.0�gr+r+r,�
<listcomp>��z,VariableManager.get_vars.<locals>.<listcomp>cs�i}z|��j||�}Wn�ty�z:|D]0}t|t�rL||�|j�O}q,||�|j�O}q,WnFty�t|d�r�t	d|j
|jf��nt	d|j
|jf��Yn0Yn0|S)N�runz)Cannot use v1 type vars plugin %s from %szInvalid vars plugin %s from %s)�get_varsrA�AttributeErrorr%rZ
get_host_varsrrr�hasattrrZ
_load_nameZ_original_path)Zplugin�path�entitiesr)Zentityr_r+r,�_get_plugin_vars�s

 z2VariableManager.get_vars.<locals>._get_plugin_varscst�j�jj|��S)z) merges all entities by inventory source )r#rAr@Z_sources)r|)rN�stager+r,�_plugins_inventory�sz4VariableManager.get_vars.<locals>._plugins_inventorycs.i}�D] }�|t�j||��d|�}q|S)z& merges all entities adjacent to play z	path '%s')r$rA)r|r)r{)rm�basedirsrNr~r+r,�
_plugins_play�sz/VariableManager.get_vars.<locals>._plugins_playcs���Sr^)rxr+)�	all_groupr+r,r4sz/VariableManager.get_vars.<locals>.all_inventorycs
��g�Sr^r+r+)rr�r+r,r3sz7VariableManager.get_vars.<locals>.all_plugins_inventorycs
��g�Sr^r+r+)r�r�r+r,r2sz2VariableManager.get_vars.<locals>.all_plugins_playcst��S)z  gets group vars from inventory )rr+)�host_groupsr+r,r1sz2VariableManager.get_vars.<locals>.groups_inventorycs���S)z/ gets plugin sources from inventory for groups r+r+)rr�r+r,r0sz:VariableManager.get_vars.<locals>.groups_plugins_inventorycs���S)z* gets plugin sources from play for groups r+r+)r�r�r+r,r/sz5VariableManager.get_vars.<locals>.groups_plugins_playcsJi}�D]<}�||�|�d|�||<�||�|�d|�||<q|S)z�
                    merges all plugin sources by group,
                    This should be used instead, NOT in combination with the other groups_plugins* functions
                zinventory group_vars for '%s'zplaybook group_vars for '%s'r+)r)�group)rmrr�r�r+r,�plugins_by_groupss
z3VariableManager.get_vars.<locals>.plugins_by_groupszCalling %s to load vars for %sz!group vars, precedence entry '%s'z.Ignoring unknown variable precedence entry: %szhost vars for '%s'zinventory host_vars for '%s'zplaybook host_vars for '%s'�factsZ
ansible_localz	play vars�r9�	variablesz�Invalid vars_files entry found: %r
vars_files entries should be either a string type or a list of string types after template expansion�varsTF)Zunsafe�cachezplay vars_files from '%s'zvars file %s was not foundZmodule_setupzTan undefined variable was found when attempting to template the vars_files item '%s')�objz4skipping vars_file '%s' due to an undefined variablezRead vars_file '%s'zXError while reading vars files - please supply a list of file names. Got '%s' of type %s)Zinclude_paramszrole '%s' varsz	task varsZinclude_varsZset_factzrole '%s' paramszinclude paramsz
extra varsz
magic vars�environmentZansible_delegated_vars�_ansible_loop_cachezdone with get_vars())ArL�debugr:�_get_magic_variablesrJrA�get_basedirZ	get_rolesZget_default_varsrrrhZPLAYBOOK_VARS_ROOT�get_search_pathr�_role�actionZ_ACTION_INCLUDE_ROLEZ
get_dep_chainr@�groupsrHrZ
get_groupsZVARIABLE_PRECEDENCE�_ALLOWED�localsrMrxr rKr!ZINJECT_FACTS_AS_VARSr"�KeyErrorZget_vars_filesrr=rr%r&�templaterZpath_dwim_relative_stackr-Zload_from_filerr
r
rZvvv�	TypeErrorr'ZDEFAULT_PRIVATE_ROLE_VARSr<�get_namer;Zget_role_paramsZget_include_paramsr��copy�delegate_to�_get_delegated_varsri�VarsWithSources�new_vars_with_sources)"rNrbrcrardreZ	use_cacherfrgr~Zall_varsZmagic_variablesZroler}r4r3r2r1r0r/r��entryr�Z
vars_filesZvars_file_itemZ	temp_vars�templarZvars_file_listZ	vars_fileZplay_search_stackZ
found_fileZ	real_filer)r*r+)	rmrr�rlr�r�r�rNr~r,rx�s
�






�
 


��

.��
�
� 

zVariableManager.get_varscsi}tj�|j���|d<tj|d<tj|d<�r�t	dd��j
D��}	dd��j
D�}
t	t|	|
��|d<|
|d	<|	|d
<|d	|d<���|d<|r�|j
r�|j
jd
d�|d<|j
j|d<t|j
j�|d<|j
j|d<|j
��|d<|jdu�r�|j��|d<��r�t|jd�}�j�s,|��j��r,d}n�j�p6d}|�sXdd�|jj|dd�D�}|�srdd�|j��D�}|dd�|d<�fdd�|dD�|d<�fdd�|D�|d <|d |d!<|j|d"<|j��D]\}
}|||
<�q�|jdu�r|�r|j|d#<|S)$z�
        Returns a dictionary of so-called "magic" variables in Ansible,
        which are special variables we set internally for use.
        roZansible_playbook_pythonZansible_config_filecSs"h|]}|��D]}|���qqSr+)Zget_all_dependenciesr�)rs�r�dr+r+r,�	<setcomp>�rvz7VariableManager._get_magic_variables.<locals>.<setcomp>cSsg|]}|���qSr+)r�)rsr�r+r+r,ru�rvz8VariableManager._get_magic_variables.<locals>.<listcomp>Zansible_role_namesZansible_play_role_namesZansible_dependent_role_namesZ
role_namesZansible_play_nameF)Zinclude_role_fqcnZ	role_nameZ	role_pathZ	role_uuidZansible_collection_nameZansible_role_nameNr�r8rncSsg|]
}|j�qSr+rq�rs�hr+r+r,ru�rvT)�pattern�ignore_restrictionscSsg|]
}|j�qSr+rqr�r+r+r,ru�rvZansible_play_hosts_allcsg|]}|�jvr|�qSr+�Z_removed_hosts�rs�x�rbr+r,ru�rvZansible_play_hostscsg|]}|�jvr|�qSr+r�r�r�r+r,ru�rvZansible_play_batchZ
play_hostsZomitZhostvars)rCr{�abspathrAr��sys�
executablerhZCONFIG_FILEr&Zroles�setr�r�Z
_role_pathrZ_uuidZ_role_collectionr@Zget_groups_dictrZ	finalized�is_template�hosts�	get_hostsrFrG�itemsrB)rNrbrcrardrerfrgr�Zdependency_role_namesZplay_role_namesr�r��optionZoption_valuer+r�r,r��sP



z$VariableManager._get_magic_variablescs�t|d�sidfS|��}|��|d<|j��|dvrL|d�|j���t|j|d��g}d}|jdu�r4|jtv�r$d}|jdkr�d}zzt	|j
�|dd�}|s��fdd	�|D�}tj|j|j�d
�}	dD]}
|
|jvr�q�q�t
|	d|
d
�t|	j||d��}Wnt�y dg}Yn0ntd|j��nD|j
du�rnz��|j
�}Wnt�yjdg}Yn0n
d}dg}t�}t|jdd�}d}
|D�]}|du�r�|||<|�_�j|jdd�}||jk�r�d}
|du�r�td|jd��t|t��stdt|�|jd��||v�r�q�d}|jdu�rz|j�|�}|du�r�|jjddd�D]}|j|k�rP|}�q��qPt |d�}n
t |d�}|j!|||ddd�||<|�d�||d<�q�d}|�r�|
�r�|}||fS)N�loopZansible_search_pathr�TZfirst_foundF)�termsr��fail_on_undefinedZconvert_barecsg|]}��|�s|�qSr+)r�)rs�t�r�r+r,ru,rvz7VariableManager._get_delegated_vars.<locals>.<listcomp>)r9r�)r��var�fileZ_subdir�s)r�r�zDFailed to find the lookup named '%s' in the available lookup pluginsZloop_varr*)r�z$Undefined delegate_to host for task:)�messager�z^the field 'delegate_to' has an invalid type (%s), and could not be converted to a string type.)Z
ignore_limitsr�rq)rbrcrarerdZinventory_hostname)"rzr�r�rAr��appendrZ	loop_withrrr�rHr��setattrr rwrrr�r:�getattrZloop_controlZavailable_variablesr�Z_dsr%rr'r@Zget_hostr��addressrrx)rNrbraZexisting_variablesZ	vars_copyr�Zhas_loopZfailZ
loop_termsZmylookupZsubdirZdelegated_host_varsZitem_varZcache_itemsr*Zdelegated_host_nameZdelegated_hostr�r�r+r�r,r�s�





��



�
z#VariableManager._get_delegated_varscCs|j�|d�dS)z-
        Clears the facts for a host
        N)rK�pop)rN�hostnamer+r+r,�clear_facts�szVariableManager.clear_factscCstt|t�stdt|���z|j|}Wnty>|}Yn(0t|t�s^td�|t|����||O}||j|<dS)�O
        Sets or updates the given facts for a host in the fact cache.
        zIthe type of 'facts' to set for host_facts should be a Mapping but is a %szCThe object retrieved for {0} must be a MutableMapping but was a {1}N)	r%rrr'rKr�rr��format)rNrcr�Z
host_cacher+r+r,�set_host_facts�s


�zVariableManager.set_host_factscCsRt|t�stdt|���z|j||O<WntyL||j|<Yn0dS)r�zRthe type of 'facts' to set for nonpersistent_facts should be a Mapping but is a %sN)r%rrr'r;r�)rNrcr�r+r+r,�set_nonpersistent_facts�s
z'VariableManager.set_nonpersistent_factscCsp||jvrt�|j|<||j|vr^t|j||t�r^t|t�r^t|j|||i�|j|<n||j||<dS)z<
        Sets a value in the vars_cache for a host.
        N)r<r:r%rr)rNrcZvarname�valuer+r+r,�set_host_variable�s

,z!VariableManager.set_host_variable)NNN)	NNNTTTNNra)NN)�__name__�
__module__�__qualname__�	frozensetr�rRr\r]�propertyrVr`rxr�r�r�r�r�r�r+r+r+r,r.Gs&

�
3
H
r.c@sdeZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)r�a"
    Dict-like class for vars that also provides source information for each var

    This class can only store the source for top-level vars. It does no tracking
    on its own, just shows a debug message with the information that it is provided
    when a particular var is accessed.
    cOst|i|��|_i|_dS)z Dict-compatible constructor N)r:r)�sources)rN�args�kwargsr+r+r,rR�szVarsWithSources.__init__cCs||�}||_|S)z@ Alternate constructor method to instantiate class with sources )r�)�clsr)r��vr+r+r,r��sz%VarsWithSources.new_vars_with_sourcescCs|j�|d�Sr^)r�rH�rNrkr+r+r,�
get_source�szVarsWithSources.get_sourcecCs*|j|}t�d||j�|d�f�|S)Nzvariable '%s' from source: %s�unknown)r)rLr�r�rH)rNrk�valr+r+r,�__getitem__�s
zVarsWithSources.__getitem__cCs||j|<dSr^�r))rNrkr�r+r+r,�__setitem__�szVarsWithSources.__setitem__cCs|j|=dSr^r�r�r+r+r,�__delitem__�szVarsWithSources.__delitem__cCs
t|j�Sr^)�iterr)r_r+r+r,�__iter__�szVarsWithSources.__iter__cCs
t|j�Sr^)�lenr)r_r+r+r,�__len__�szVarsWithSources.__len__cCs|j�|�Sr^)r)�__contains__r�r+r+r,r��szVarsWithSources.__contains__cCst�|j��|j���Sr^)r�r�r)r�r�r_r+r+r,r��szVarsWithSources.copyN)r�r�r��__doc__rR�classmethodr�r�r�r�r�r�r�r�r�r+r+r+r,r��s
r�)@Z
__future__rrrr'Z
__metaclass__rCr��collectionsr�collections.abcrrrZhashlibr	Zjinja2.exceptionsr
ZansiblerrhZansible.errorsrr
rrrrZansible.inventory.hostrZansible.inventory.helpersrrZansible.module_utils._textrZansible.module_utils.sixrrZansible.plugins.loaderrZansible.vars.fact_cacherZansible.templaterZansible.utils.displayrZansible.utils.listifyrZansible.utils.varsrrrZansible.utils.unsafe_proxyr Zansible.vars.cleanr!r"Zansible.vars.pluginsr#r$rLr-r.r�r+r+r+r,�<module>s< |