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/playbook/__pycache__/base.cpython-39.pyc
a

�)g��@sZddlmZmZmZeZddlZddlZddlZddl	m	Z
ddlmZddl
mZddlmZddlmZddlmZmZmZmZdd	lmZdd
lmZddlmZmZddlm Z dd
l!m"Z"m#Z#m$Z$m%Z%ddl&m'Z'm(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1m2Z2m3Z3e-�Z4dd�Z5Gdd�d�Z6Gdd�d�Z7Gdd�de7�Z8dS)�)�absolute_import�division�print_functionN)�copy)�cache)�UndefinedError)�	constants)�context)�AnsibleError�AnsibleParserError�AnsibleUndefinedVariable�AnsibleAssertionError)�string_types)�boolean)�to_text�	to_native)�
DataLoader)�	Attribute�FieldAttribute�ConnectionFieldAttribute�NonInheritableFieldAttribute)�
module_loader�
action_loader)�_get_collection_metadata�AnsibleCollectionRef)�Display��Sentinel)�combine_vars�isidentifier�
get_unique_idc
Csvdttfdd�i}g}tj}t|t�o8d|vo8t|�dk}|rh|shd�tt|���}|�	dj
|d��n�|�rJ|r||�	d	�t|dt�s�|�	d
j
|dd��n�t|d���t|���}|r�|�	d�
d�|���g}	|�
�D]H\}
}|
|dvr�q�|d|
}t||d
�s�|	�	d|
||df�q�|	�rJ|�	d�
d�|	���|�rr|�dd�
|��t�d�|��dS)N�extend_group�list)�types�	errortype�metadata��, z7The only expected key is metadata, but got keys: {keys})�keysz-The group contains multiple metadata entries.z0The metadata is not a dictionary. Got {metadata})r%z*The metadata contains unexpected keys: {0}r#z%s is %s (expected type %s)r$z/The metadata contains unexpected key types: {0}rzNInvalid metadata was found for action_group {0} while loading module_defaults.� )r"r�CZVALIDATE_ACTION_GROUP_METADATA�
isinstance�dict�len�join�sorted�append�format�setr(�items�insert�display�warning)
�action�found_group_metadata�
fq_group_nameZvalid_metadataZmetadata_warnings�validateZ
metadata_onlyZ
found_keysZunexpected_keysZunexpected_typesZfieldZrequirement�value�r<�9/usr/lib/python3.9/site-packages/ansible/playbook/base.py�_validate_action_group_metadata"s>��
r>c@seZdZdd�Zddd�ZdS)�_ClassPropertycCs
||_dS�N)�name)�self�ownerrAr<r<r=�__set_name__Jsz_ClassProperty.__set_name__NcCst|d|j����S)N�_)�getattrrA)rB�objZobjtyper<r<r=�__get__Msz_ClassProperty.__get__)N)�__name__�
__module__�__qualname__rDrHr<r<r<r=r?Isr?c@seZdZe�Zeedd���Zdd�Ze	dd��Z
d;dd	�Zd
d�Zd<d
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd=dd�Zdd�Ze	dd��Zd>d d!�Zd?d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd@d1d2�Zd3d4�Zd5d6�Z d7d8�Z!d9d:�Z"dS)A�FieldAttributeBasecCsbi}t|j�D]N}t|j���D]:\}}t|t�s4q |||<|jr t||j|�|||j<q q|Sr@)	�reversed�__mro__r"�__dict__r3r+r�alias�setattr)�cls�fattributesZ	class_objrA�attrr<r<r=�_fattributesUs
zFieldAttributeBase._fattributescCs2d|_d|_d|_d|_d|_t�|_t�|_dS)NF)	�_loader�_variable_manager�
_validated�	_squashed�
_finalizedr �_uuidr,�vars�rBr<r<r=�__init__cszFieldAttributeBase.__init__cCs|jSr@)rZr]r<r<r=�	finalizeduszFieldAttributeBase.finalizedrcCs�|dkrt�d�t�dd||jj|t|�f�t|d�rz|jrz|j�|d�|j��}|rz|D]}|�|d�qft|d�r�|j	r�|j	�|d�dS)	zf this is never called from production code, it is here to be used when debugging as a 'complex print' rzEDUMPING OBJECT ------------------------------------------------------z%s- %s (%s, id=%s)r)�_parent��_playN)
r5�debug�	__class__rI�id�hasattrr`�dump_me�
get_dep_chainrb)rB�depth�	dep_chainZdepr<r<r=rgys
"
zFieldAttributeBase.dump_mecCs|S)zD infrequently used method to do some pre-processing of legacy terms r<)rB�dsr<r<r=�preprocess_data�sz"FieldAttributeBase.preprocess_dataNcCs�|durtd|��t|d|�||_|dur6||_nt�|_|�|�}|�|�t|j�	�t
�d�d�D]L\}}||vrjt|d|d�}|r�t||||||��qjt||||�qj|�
�|S)z4 walk the input datastructure and assign any values Nz%ds (%s) should not be None but it is.�_dsr&)�keyz_load_%s)r
rQrWrVrrl�_validate_attributesr/rSr3�operator�
itemgetterrFr:)rBrkZvariable_manager�loaderrArT�methodr<r<r=�	load_data�s"

 zFieldAttributeBase.load_datacCs&zt|d�WSty YdS0dS)Nrm)rF�AttributeErrorr]r<r<r=�get_ds�szFieldAttributeBase.get_dscCs|jSr@)rVr]r<r<r=�
get_loader�szFieldAttributeBase.get_loadercCs|jSr@)rWr]r<r<r=�get_variable_manager�sz'FieldAttributeBase.get_variable_managercCsJ|�|�}td�}|rFt|t�rF||vrFtd|d�|�f|��d��|S)N)�alwaysZ	on_failedZon_unreachableZ
on_skipped�neverz9'%s' is not a valid value for debugger. Must be one of %sr'�rG)�template�	frozensetr+rrr.rv)rBrTr;�templarZvalid_valuesr<r<r=�_post_validate_debugger�s

z*FieldAttributeBase._post_validate_debuggercCs8t|j�}|D]$}||vrtd||jjf|d��qdS)z}
        Ensures that there are no keys in the datastructure which do
        not map to attributes for this object.
        z&'%s' is not a valid attribute for a %sr{N)r}rSrrdrI)rBrkZvalid_attrsrnr<r<r=ro�s
z'FieldAttributeBase._validate_attributescCs�|durin|}|js�|j��D]~\}}t|d|d�}|rP|||t||��q t|d|��t�}|dur |jdkr t|ttf�r t	d|t
|�f|��d��q d|_dS)z6 validation that is done at parse time, not load time Nz_validate_%srE�stringz[The field '%s' is supposed to be a string type, however the incoming data structure is a %sr{T)rXrSr3rFr�isar+r"r,r�typerv)rB�all_varsrA�	attributersr;r<r<r=r:�s 
��zFieldAttributeBase.validatecCs�|durdSt|t�s|g}g}|D]�}t|t�s:td��i}|��D]�\}}|�d�r�|�d�d}|jdur~|�|�\}}	d|}|||<qFt	|�d��dkr�d|}|�
|�}
|
r�|||
<|�d�rF|j
|�dd�dd	�}
|
rF|||
<qF|�|�q$|S)
Nz�The field 'module_defaults' is supposed to be a dictionary or list of dictionaries, the keys of which must be static action, module, or group names. Only the values may contain templates. For example: {'ping': "{{ ping_defaults }}"}zgroup/����.�zansible.legacy.zansible.builtin.F��	mandatory)
r+r"r,rr3�
startswith�split�play�_resolve_groupr-�_resolve_action�replacer0)rBrAr;Zvalidated_module_defaultsZ
defaults_dictZvalidated_defaults_dictZdefaults_entry�defaultsZ
group_name�dummy�resolved_actionr<r<r=�_load_module_defaults�s@

�





�
z(FieldAttributeBase._load_module_defaultscCsJt|d�r|j}n$t|d�r2t|jd�r2|jj}n|}|jjdkrFdS|S)Nrbr`ZPlay)rfrbr`rdrI)rBr�r<r<r=r�!s

zFieldAttributeBase.playTcCszt�|�sd}|d|}nd�|�d�dd��}||jjvrP||jj|fSzt|��di�}Wn<ty�|s�t	�
d|�|gfYStd|��Yn0|�|d�d}|�||�|��}|dur�|s�t	�
d|�|gfStd|��g}g}d}	|D]�}
t|
t
��sjt|
|	|�t|
d	t��rd
}	|
d	�dg�}t|t
��rV|g}t|t��sg}�qt�|
��s�|d|
}
|j|
dd�}|�r|�|��q|D]2}
|
|jjv�r�g|jj|
<|jj|
�|��q�||jj|<|D]�}t�|��s|d|}|j|dd�\}
}|D]2}
|
|jjv�r<g|jj|
<|jj|
�|��q|jj|�|�|�|��q�||fS)
Nzansible.builtinr�rra�
action_groupszMError loading module_defaults: could not resolve the module_defaults group %sr�Fr%Tr!r�)rZ
is_valid_fqcrr.r�r��_group_actionsr�get�
ValueErrorr5�vvvvvrr+rr>r,r"r�r0�_action_groupsr��extend)rBr9r�Zcollection_namer��
resource_name�action_groupZresolved_actionsZinclude_groupsr8r7r�Z
include_groupr��
group_actionsr<r<r=r�0st
�z!FieldAttributeBase._resolve_groupcCsjt�|�}|jr,|js,t�|�}|jr<|}n|js<t�|�}|jrH|jS|rXtd|��t�d|�dS)Nz.Could not resolve action %s in module_defaults)	rZfind_plugin_with_contextZresolvedZ
action_pluginrZ
resolved_fqcnrr5r�)rB�action_namer�r	Zpreferr<r<r=r��s


z"FieldAttributeBase._resolve_actioncCs.|js*|jD]}t||t||��qd|_dS)z�
        Evaluates all attributes and sets them to the evaluated version,
        so that all future accesses of attributes do not need to evaluate
        parent attributes.
        TN)rYrSrQrF)rBrAr<r<r=�squash�s
zFieldAttributeBase.squashc
Cs�z|��}Wn0ty<}ztd|d��WYd}~n
d}~00|jD]"}t||tt|d|��t���qD|j|_|j	|_	|j
|_
|j|_|j|_t
|d�r�|j|_|S)z=
        Create a copy of this object and return it.
        zTExceeded maximum object depth. This may have been caused by excessive role recursion)�orig_excNrErm)rd�RuntimeErrorr
rSrQ�shallowcopyrFrrVrWrXrZr[rfrm)rBZnew_me�erAr<r<r=r�s"
 
zFieldAttributeBase.copycCs|jdkrt|�}�n|jdkr,t|�}�n�|jdkrBt|�}�n�|jdkr\t|dd�}�n�|jdkr�t|t�r�d|vr�|�dd	�}t|�}�n�|jd
k�r>|dur�g}nt|t�s�|g}|j	du�r|D]p}t||j	�s�t
d||j	|t|�f|��d��q�|j
r�|j	tkr�|du�s$|��d	kr�t
d
|f|��d��q�n�|jdk�r�|du�r\t�}n.t|ttf��s�t|t��r�|�d�}n|g}t|t��st|�}nv|jdk�r�|du�r�t�}nt|t��std|��n>|jdk�rt||j��s
td||jt|�f��|j|d�|S)Nr��int�float�boolT)�strict�percent�%�r"z@the field '%s' should be a list of %s, but the item '%s' is a %sr{z8the field '%s' is required, and cannot have empty valuesr2�,r,z%s is not a dictionary�classz'%s is not a valid %s (got a %s instead))r~)r�rr�r�rr+rr�r"Zlistofrr�rv�required�stripr2r�r,�	TypeError�
class_type�
post_validate)rBrAr�r;r~�itemr<r<r=�get_validated_value�s^





��


z&FieldAttributeBase.get_validated_valuecCs`|j|}t|t�r"t||t�n:zt|||j|dd��WntyZt||t�Yn0dS)z9 set to parent inherited value or Sentinel as appropriateT)�omitN)rSr+rrQrZ_get_parent_attributeru)rBrAr�r<r<r=�set_to_context�s

z!FieldAttributeBase.set_to_contextc	Cs�|j�d�}|j��D�]�\}}|jrVt||�}|dvr|�|�rt�d||f�qt||�dur||j	snqq�t
d|��n|js�|jj
dvr�qz�t|d|d�}|r�||t||�|�}n&|jdkr�t||�}n|�t||��}|dur�||kr�|�|�Wq|du�r|�||||�}t|||�Wqttf�yz}z6t||�}t
d	|||j|f|��|d
��WYd}~qd}~0ttf�y�}zX|j�r�|dk�r�|dk�r�d
t|�}nd|t|�f}t
||��|d
��WYd}~qd}~00qd|_dS)z�
        we can't tell that everything is of the right type until we have
        all the variables.  Run basic types (from isa) as well as
        any _post_validate_<foo> functions.
        r�)r\z]"%s" is not templatable, but we found: %s, it will not be templated and will be used "as is".Nz*the field '%s' is required but was not set)ZTaskZHandlerZPlayContextz_post_validate_%sr�z_the field '%s' has an invalid value (%s), and could not be converted to an %s.The error was: %s�rGr�rA�argszIThe task includes an option with an undefined variable. The error was: %sz\The field '%s' has an invalid value, which includes an undefined variable. The error was: %sT)Zavailable_variablesr�rSr3�staticrFZis_templater5r6r�r�always_post_validaterdrIr�r|r�r�rQr�r�rvrrZ_fail_on_undefined_errorsrrZ)	rBr~Z
omit_valuerAr�r;rsr��msgr<r<r=r��sT
�



��
*z FieldAttributeBase.post_validatec
Cs�dd�}zvt|t�r*||�t|j|�WSt|t�rj|j}|D]$}t|t�sPt�||�t||�}q>|WS|durxiWSt�Wnvty�}z"td|jj||d��WYd}~nFd}~0t	y�}z&td|jj|f||d��WYd}~n
d}~00dS)z�
        Vars in a play can be specified either as a dictionary directly, or
        as a list of dictionaries. If the later, this method will turn the
        list into a single dictionary.
        cSs"|D]}t|�std|��qdS)Nz!'%s' is not a valid variable name)rr�)rkrnr<r<r=�_validate_variable_keysEsz>FieldAttributeBase._load_vars.<locals>._validate_variable_keysNzIVars in a %s must be specified as a dictionary, or a list of dictionariesr�z2Invalid variable name in vars specified for %s: %s)
r+r,rr\r"r�rrdrIr�)rBrTrkr�r�r�r�r<r<r=�
_load_vars>s,


�zFieldAttributeBase._load_varsFcCsft|t�s|g}t|t�s |g}dd�|D�}dd�|D�}|rJ||}n||}dd�t�|�D�S)z�
        Will extend the value given with new_value (and will turn both
        into lists if they are not so already). The values are run through
        a set to remove duplicate values.
        cSsg|]}|tur|�qSr<r��.0�vr<r<r=�
<listcomp>o�z4FieldAttributeBase._extend_value.<locals>.<listcomp>cSsg|]}|tur|�qSr<rr�r<r<r=r�pr�cSsg|]\}}|dur|�qSr@r<)r��irEr<r<r=r�wr�)r+r"�	itertools�groupby)rBr;Z	new_value�prependZcombinedr<r<r=�
_extend_value`s


z FieldAttributeBase._extend_valuecCsPi}|j��D]<\}}t||�}|jdkrBt|d�rB|��||<q|||<q|S)z6
        Dumps all attributes to a dictionary
        r��	serialize)rSr3rFr�rfr�)rB�attrsrAr�rTr<r<r=�
dump_attrsys

zFieldAttributeBase.dump_attrscCsv|��D]\\}}||jvr|j|}|jdkrXt|t�rX|��}|�|�t|||�qt|||�qd|_d|_	dS)z4
        Loads attributes from a dictionary
        r�TN)
r3rSr�r+r,r��deserializerQrZrY)rBr�rTr;r�rGr<r<r=�
from_attrs�s


zFieldAttributeBase.from_attrscCs*|��}|j|d<|j|d<|j|d<|S)a0
        Serializes the object derived from the base object into
        a dictionary of values. This only serializes the field
        attributes for the object, so this may need to be overridden
        for any classes which wish to add additional items not stored
        as field attributes.
        �uuidr_�squashed)r�r[rZrY)rB�reprr<r<r=r��s
	


zFieldAttributeBase.serializecCs�t|t�std|t|�f��|j��D],\}}||vrJt||||�q(|�|�q(t|d|�d��|�dd�|_	|�dd�|_
dS)z�
        Given a dictionary of values, load up the field attributes for
        this object. As with serialize(), if there are any non-field
        attribute data members, this method will need to be overridden
        and extended.
        z&data (%s) should be a dict but is a %sr[r�r_Fr�N)r+r,r
r�rSr3rQr�r�rZrY)rB�datarAr�r<r<r=r��s
zFieldAttributeBase.deserialize)r)NN)N)T)T)F)#rIrJrKr?rS�classmethodrrUr^�propertyr_rgrlrtrvrwrxrror:r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r<r<r<r=rLQs@


*
7

U
3E"

rLc@sjeZdZedddd�Zede�d�d�Ze	dd�Z
e	de�d	�d�Zed
ddd�Ze	d
ddd�Z
e	d
ddd�Ze	dejd�Ze	dd�Ze	dd�Ze	dd�Ze	de�d�d�Ze	de�d�d�Ze	dejd�Ze	ddd�Ze	dejd�Ze	dd�Ze	de�d�d�Ze	de�d�d�Ze	de�d�d�Ze	de�d�d�Z e	de�d�d�Z!gZ"dd�Z#dd�Z$dd�Z%dS)�Baser�r�T)r��defaultr��
connection)r�r�r�)r��remote_userr,�d)r��priorityr�r")r�r�r�r��check�diffr�become�
become_method�become_user�become_flags�
become_execCshd}zd|jj|jjf}WnFtybz d|jjjj|jjjjf}Wnty\Yn0Yn0|S)zE return the absolute path of the playbook object and its line number r�z%s:%s)rmZ_data_sourceZ_line_numberrur`rb)rB�pathr<r<r=�get_path�s z
Base.get_pathcCs"t|d�r|jr|j��SdSdS)Nr`)rfr`rhr]r<r<r=rh�s
zBase.get_dep_chaincCsNg}|��}|r(|�tdd�|D���tj�|���}||vrJ|�|�|S)z�
        Return the list of paths you should search for files, in order.
        This follows role/playbook dependency chain.
        cSsg|]}t|d�r|j�qS)�
_role_path)rfr�)r��xr<r<r=r�
r�z(Base.get_search_path.<locals>.<listcomp>)rhr�rM�osr��dirnamer�r0)rBZ
path_stackrjZtask_dirr<r<r=�get_search_paths
zBase.get_search_pathN)&rIrJrKrrArr	Zcliargs_deferred_getr�r�portr�r\Zmodule_defaultsZenvironmentr*ZDEFAULT_NO_LOGZno_logZrun_once�
ignore_errorsZignore_unreachableZ
check_moder�ZANY_ERRORS_FATALZany_errors_fatalZthrottleZTASK_TIMEOUT�timeoutZdebuggerr�r�r�r�r�ZDEPRECATED_ATTRIBUTESr�rhr�r<r<r<r=r��s4





r�)9Z
__future__rrrr�Z
__metaclass__r�rpr�rr��	functoolsrZjinja2.exceptionsrZansiblerr*r	Zansible.errorsr
rrr
Zansible.module_utils.sixrZ)ansible.module_utils.parsing.convert_boolrZansible.module_utils._textrrZansible.parsing.dataloaderrZansible.playbook.attributerrrrZansible.plugins.loaderrrZ2ansible.utils.collection_loader._collection_finderrrZansible.utils.displayrZansible.utils.sentinelrZansible.utils.varsrrr r5r>r?rLr�r<r<r<r=�<module>s:'w