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: //proc/self/root/lib/python3.9/site-packages/ansible/plugins/__pycache__/loader.cpython-39.pyc
a

�)g��@s�ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZddlmZddlmZddlmZddlmZdd	lmZdd
lmZmZmZmZddlm Z m!Z!m"Z"ddl#m$Z$dd
l%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1m2Z2ddl3m4Z4m5Z5ddl6m7Z7ddl8m9Z9m:Z:ddl;m<Z<zddl=m>Z>ddl?m@Z@WneA�y�dZ>dZ@Yn0ddlBZCe7�ZDedddg�ZEdd�ZFdd�ZGdzdd �ZHd!d"�ZIGd#d$�d$eJ�ZKGd%d&�d&eJ�ZLGd'd(�d(�ZMGd)d*�d*eM�ZNd{d,d-�ZOd.d/�ZPd0d1�ZQd2d3�ZRd4d5�ZSeP�ZTeS�eMd6d7ejUd8�ZVeMd9d:ejWd;d<d=�ZXeMd>d?ejYd@�ZZeMdAdBej[dC�Z\eMdDdEej]dFdGdHidIdJ�Z^eMdKdLdMdM�Z_eMdNdOej`dP�ZaeMdNdQejbdR�ZceMdNdQejbdR�ZdeMdSdTejedUdVd=�ZfeNdWdXejgdYe�ZheNdZd[ejid\e�ZjeMd]d^ejkd_d`d=�ZleMdadbejmdcddd=�ZneMdedfejodg�ZpeMdhdiejqdjdkd=�ZreMdldmejsdndod=�ZteMdpdqejudr�ZveMdsdtejwdudvd=�ZxeMdwdxejydy�ZzdS)|�)�absolute_import�division�print_functionN)�defaultdict�
namedtuple)�
format_exc�)�AnsibleJinja2Filter)�AnsibleJinja2Test)�__version__)�	constants)�AnsibleError�AnsiblePluginCircularRedirect�AnsiblePluginRemovedError�(AnsibleCollectionUnsupportedVersionError)�to_bytes�to_text�	to_native)�
import_module)�string_types)�	from_yaml)�
AnsibleLoader)�get_plugin_class�MODULE_CACHE�
PATH_CACHE�PLUGIN_PATH_CACHE)�AnsibleCollectionConfig�AnsibleCollectionRef)�_AnsibleCollectionFinder�_get_collection_metadata)�Display)�
add_fragments�find_plugin_docfile)�
_is_unsafe)�SpecifierSet)�Version�get_with_context_result�object�plugin_load_contextcCsdd�t���D�S)NcSs"g|]\}}t|t�r||f�qS�)�
isinstance�PluginLoader)�.0�name�objr)r)�:/usr/lib/python3.9/site-packages/ansible/plugins/loader.py�
<listcomp>8�z*get_all_plugin_loaders.<locals>.<listcomp>)�globals�itemsr)r)r)r/�get_all_plugin_loaders7sr4cCs|tj�t|dd��}tj�|�rft�D]<\}}|jr&tj�|t|j��}tj�|�r&|�t	|��q&nt
�dt	|��dS)z3 add any existing plugin dirs in the path provided �surrogate_or_strict��errorszFIgnoring invalid path provided to plugin path: '%s' is not a directoryN)�os�path�
expanduserr�isdirr4�subdir�join�
add_directoryr�display�warning)r9�b_pathr-r.�plugin_pathr)r)r/�add_all_plugin_dirs;srCcCs�|s|d}|rtt|t�r|tj�|�}zt�|�}WntyFd}Yn0|dur|t��D]}||j	vrX|j
}q|qXntd��t�|�}|s�td|��|r�t|d|�|S)N�shz;Either a shell type or a shell executable must be provided z.Could not find the shell plugin required (%s).�
executable)
r*rr8r9�basename�shell_loader�get�	Exception�allZCOMPATIBLE_SHELLSZSHELL_FAMILYr
�setattr)Z
shell_typerEZshell_filename�shellr)r)r/�get_shell_pluginHs*



rMcCs0ttjtd|�}|D]}|j|dd�qdS)Nz	%s_loaderT)�with_subdir)�getattr�sys�modules�__name__r>)Zwhich_loader�paths�loaderr9r)r)r/�add_dirs_to_loaderisrUc@seZdZdd�ZdS)�PluginPathContextcCs||_||_dS�N)r9�internal)�selfr9rXr)r)r/�__init__qszPluginPathContext.__init__N)rR�
__module__�__qualname__rZr)r)r)r/rVpsrVc@s@eZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�PluginLoadContextcCsjd|_g|_g|_g|_g|_d|_d|_d|_d|_d|_	d|_
d|_d|_g|_
d|_d|_d|_dS�NF)�
original_name�
redirect_list�
error_list�import_error_list�
load_attempts�pending_redirect�exit_reason�plugin_resolved_path�plugin_resolved_name�plugin_resolved_collection�
deprecated�removal_date�removal_version�deprecation_warnings�resolved�_resolved_fqcn�
action_plugin�rYr)r)r/rZws"zPluginLoadContext.__init__cCsf|js
dS|js`|jd}t�|�r<|�d�r<|�d�d}|jrZt�|�sZ|jd|}||_|jS)N����ansible.legacy.�.)rmrnr`r�
is_valid_fqcr�
startswith�splitrh)rYZfinal_pluginr)r)r/�
resolved_fqcn�s
zPluginLoadContext.resolved_fqcncCs�|s|S|�dd�pd}|�dd�}|�dd�}|dur<d}d�||rJdnd|�}tj||||d�d|_|rt||_|r~||_|j�|�|S)	N�warning_text�rjrkz{0} has been deprecated.{1}{2}� )�date�version�collection_nameT)rH�formatr?rirjrkrl�append)rYr-�deprecationr}rxrjrkr)r)r/�record_deprecation�s z$PluginLoadContext.record_deprecationcCs.d|_||_||_||_||_d|_||_|S)NT)rdrgrfrhrermro)rYZ
resolved_name�
resolved_pathZresolved_collectionreror)r)r/�resolve�szPluginLoadContext.resolvecCs ||_d�|j|�|_d|_|S)Nz+pending redirect resolution from {0} to {1}F)rdr~r_rerm)rYZ
redirect_namer)r)r/�redirect�szPluginLoadContext.redirectcCsd|_||_d|_|Sr^)rdrerm)rYrer)r)r/�nope�szPluginLoadContext.nopeN)
rRr[r\rZ�propertyrwr�r�r�r�r)r)r)r/r]vs

r]c@seZdZdZd<dd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
d=dd�Zd>dd�Zd?dd�Zdd�Zd@dd �ZdAd!d"�ZdBd#d$�ZdCd&d'�ZdDd(d)�Zd%ddde�fd*d+�ZdEd,d-�ZdFd.d/�ZeZd0d1�ZdGd2d3�Zd4d5�Zd6d7�ZdHd8d9�Z d:d;�Z!dS)Ir+z�
    PluginLoader loads plugins from the configured plugin directories.

    It searches for plugins by iterating through the combined list of play basedirs, configured
    paths, and the python path.  The first match is used.
    NcCs�|durin|}||_||_||_||_||_|rDt|t�sD|g}n|sLg}||_|tvrbit|<|t	vrrdt	|<|t
vr�tt�t
|<g|_
t||_t	||_t
||_t�|_dSrW)�
class_name�
base_class�packager<�aliasesr*�list�configrrrr�dict�_extra_dirs�
_module_cache�_paths�_plugin_path_cache�set�_searched_paths)rYr�r�r�r<r��required_base_classr)r)r/rZ�s,


zPluginLoader.__init__cCst�|j�SrW)r� legacy_plugin_dir_to_plugin_typer<rpr)r)r/�type�szPluginLoader.typecCsd�|j�S)NzPluginLoader(type={0}))r~r�rpr)r)r/�__repr__�szPluginLoader.__repr__cCs`tjrd|_nNit|j<dt|j<tt�t|j<t|j|_	t|j|_t|j|_
t�|_dSrW)
�CZOLD_PLUGIN_CACHE_CLEARINGr�rr�rrr�rr�r�r�r�rpr)r)r/�
_clear_caches�s

zPluginLoader._clear_cachescCs�|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�t|<|�d�t|<|�||||||�|�d	g�|_|�d
t��|_dS)z
        Deserializer.
        r�r�r�r<r�r�rrr�r�N)rHrrrZr�r�r�)rY�datar�r�r�r<r�r�r)r)r/�__setstate__
s





zPluginLoader.__setstate__cCs8t|j|j|j|j|j|j|j|jt	|jt
|jd�
S)z
        Serializer.
        )
r�r�r�r�r<r�r�r�rr)r�r�r�r�r�r<r�r�r�rrrpr)r)r/�__getstate__s�zPluginLoader.__getstate__cCs,g}|D]}||vr|�|�qtj�|�S)z; Returns a string suitable for printing of the search path )rr8�pathsepr=)rYrS�ret�ir)r)r/�format_paths/s
zPluginLoader.format_pathscCs|�|jdd��S)NF��subdirs)r��
_get_pathsrpr)r)r/�print_paths9szPluginLoader.print_pathscCsRg}|�|�tj|dd�D]0\}}}d|vr|D]}|�tj�||��q2q|S)NT)�followlinksz__init__.py)rr8�walkr9r=)rY�dir�results�rootr��files�xr)r)r/�_all_directories<s
zPluginLoader._all_directoriesTcCsv|js
gSt|d�s^t|j�}|j�d�dd�}|D]}t||�}q6ttj�|j	�dd�|_
|rn|�|j
�S|j
gS)z# Gets the path of a Python package �package_pathrsrNr5r6)r��hasattr�
__import__rvrOrr8r9�dirname�__file__r�r�)rYr��m�partsZ
parent_modr)r)r/�_get_package_pathsEs

zPluginLoader._get_package_pathscCs�|jdur|jSdd�|jD�}|jdur�|jD]�}tj�tj�|��}|r�t�d|�t�d|�}|D]4}t|dd�}tj�	|�rl||vrl|�
t|d��qlt|dd�}||vr0|�
t|d��q0|�d	d�|j
|d
�D��|jdd�d
�||_|S)zE Return a list of PluginPathContext objects to search for plugins in NcSsg|]}t|d��qS)F�rV�r,�pr)r)r/r0]r1z8PluginLoader._get_paths_with_context.<locals>.<listcomp>z%s/*z%s/*/*r5r6FcSsg|]}t|d��qS)Tr�r�r)r)r/r0qr1r�cSs|j�d�S)Nz/windows)r9�endswith)r�r)r)r/�<lambda>�r1z6PluginLoader._get_paths_with_context.<locals>.<lambda>��key)r�r�r�r8r9�abspathr:�globrr;rrV�extendr��sort)rYr�r�r9�contents�cr)r)r/�_get_paths_with_contextTs&


z$PluginLoader._get_paths_with_contextcCs|j|d�}dd�|D�S)z1 Return a list of paths to search for plugins in r�cSsg|]
}|j�qSr))r9)r,�path_with_contextr)r)r/r0�r1z+PluginLoader._get_paths.<locals>.<listcomp>)r�)rYr�Zpaths_with_contextr)r)r/r��szPluginLoader._get_pathscCs�|jr�t|j�}|tjvr�tj�||�s�tt|dd�|d���}|r�t	||t
|dkd�d|vr�t|dt�r�tj�
|||d�t�d||f�dS)	zf Reads plugin docs to find configuration setting definitions, to push to config manager for later use Z
DOCUMENTATIONry)�	file_name�module)�fragment_loaderZ	is_module�optionsz%Loaded config def from plugin (%s/%s)N)r�rr�ZCONFIGURABLE_PLUGINSr�Zhas_configuration_definitionrrOZget_single_datar!r�r*r�Z+initialize_plugin_configuration_definitionsr?�debug)rYr-r�r9�	type_nameZdstringr)r)r/�_load_config_defs�s
zPluginLoader._load_config_defsFcCsXtj�|�}|durT|r(tj�||j�}||jvrT|j�|�|��t�	d|�dS)z1 Adds an additional directory to the search path NzAdded %s to loader search path)
r8r9�realpathr=r<r�rr�r?r�)rYZ	directoryrNr)r)r/r>�s
zPluginLoader.add_directorycCs�t|j�}|sdSzt|jd�|��Wnty<Yn0t|dd�}|sRdS|jrld�|j|jg�}n|j}|�di��|i��||d�}|s�|�di��|i��|d�}|S)Nz.plugins.{0}Z_collection_metars�plugin_routing)	rZ n_python_collection_package_namer~�ImportErrorrOr�r=�resourcerH)rY�acr�plugin_type�	extensionZcollection_pkg�collection_metaZsubdir_qualified_resource�entryr)r)r/�_query_collection_routing_meta�s"
 z+PluginLoader._query_collection_routing_metac	Cs�d|_t�|j�}t�||�}|j|||d�}d}|�rb|�dd�}	|sX|�||	|j�|�dd�}
|
r�|
�d�}|
�d�}|
�d�p�d	}
d
�	||
r�dnd	|
�}
t
j|
||d|jd
�}||_||_
d|_||_t||d��|�dd�}|�rLt�|��std|j�d|�d|�d���t
�d�	|||��||jv�rB|j�|�|�|�S|jdk�rb|�d�}t|jdd�}d�	|j|�}|�r�||7}tj�|j�}|�s�zt|j�}Wn&t�y�|�d�	|j��YS0tj �!|j"�}tj �#||�}tj �$|��r"|�%|t&|�|jd�	||j�|�S|�r@|�d�	t&|�|j��Sdd�t'�(tj �#||�d�D�}|�s||�d �	||j��St)|�}t*|�d!k�r�t
�+d"d#�#|��|�%|t&|d$�|jd%�	||j�|�S)&z�Search builtin paths to find a plugin. No external paths are searched,
        meaning plugins inside roles inside collections will be ignored.
        F)r�Nr��	tombstonerjrkrxryz{0} has been removed.{1}{2}rzT)�msgr|r{�removedr}�r(r��Collection � contains invalid redirect for �: �6. Redirects must use fully qualified collection names.z"redirecting (type: {0}) {1} to {2}rQro�strictr6�{0}.{1}zPython package {0} not foundz found exact match for {0} in {1}zno match for {0} in {1}cSs(g|] }tj�|�r|�tj�s|�qSr))r8r9�isfiler�r��MODULE_IGNORE_EXTS�r,�fr)r)r/r00s�z0PluginLoader._find_fq_plugin.<locals>.<listcomp>z.*z+failed fuzzy extension match for {0} in {1}rzDFound several possible candidates for the plugin but using first: %s�,rz*found fuzzy extension match for {0} in {1}),rmrr�r<Z	from_fqcrr�rHr��
collectionr~r?�get_deprecation_messagerjrkrerrtr
Zvvr`rr�r�rr��n_python_package_namerPrQrr�r�r8r9r�r�r=�existsr�rr�Ziglob�sorted�lenr�)rY�fq_namer�r(�ignore_deprecatedr�r�Zrouting_metadataror�r�rjrkrxZremoved_msgr�Z
n_resource�	full_name�pkgZpkg_pathZn_resource_pathZfound_filesr)r)r/�_find_fq_plugin�s�

��

���zPluginLoader._find_fq_pluginrycCs(|�|||||�}|jr$|jr$|jSdS)z Find a plugin named name N)�find_plugin_with_contextrmrf)rYr-�mod_typer��
check_aliases�collection_list�resultr)r)r/�find_plugin@szPluginLoader.find_plugincCs|t�}||_|j||||||d�}|jr^|j|jvrHtd�|j|j���|j}d|_|}qq^q|jrxt�	d�||j��|S)zg Find a plugin named name, returning contextual info about the load, recursively resolving redirection r�z.plugin redirect loop resolving {0} (path: {1})Nz;errors were encountered during the plugin load for {0}:
{1})
r]r_�_resolve_plugin_steprdr`rr~rar?r@)rYr-r�r�r�r�r(r�r)r)r/r�Hs
z%PluginLoader.find_plugin_with_contextcs�|std��|j���d|_�t|jvr<d���|_|S|rF|}n|jrRd}nd}t	�
��sf|�rڈ�d��s�d�vs~|s��g}n�fdd	�|D�}|D�]}	z�|j�|	�|	�d
�r�|�
��d�||||�}n2|j|	|||d�}|j�r|	|jv�r|j�|	�|j�s|j�r |WSWq�tttf�y>�Yq�t�yn}
z|j�|
�WYd}
~
q�d}
~
0t�y�}z|j�t|��WYd}~q�d}~00q�|j�r�tjd
��d�|j��d�d���|_|S|�
�||||�S)NzA PluginLoadContext is requiredFz#{0} matched a defined plugin filterz.pyryZAnsiblerscsg|]}d�|���qS)r�)r~)r,r��r-r)r/r0�r1z5PluginLoader._resolve_plugin_step.<locals>.<listcomp>zansible.legacyrr)r(r�z)plugin lookup for {0} failed; errors: {1}z; )r�zno matches found for {0})�
ValueErrorr`rrm�_PLUGIN_FILTERSr�r~rer�rrtrurc�_find_plugin_legacy�removeprefixr�rdrrrr�rbrIrarr?r�r=)rYr-r�r�r�r�r(�suffixZ
candidatesZcandidate_nameZie�exr)r�r/r�fsR

�
� (z!PluginLoader._resolve_plugin_stepcsxd|_|r�j�||�}�j|}zF||}|j|_||_|jrDdnd|_|jrXd|n||_	d|_|WSt
yzYn0�fdd����D�D�]}|j}t|��t
�d|�|j�|�|j}	z�fd	d�t���D�}
Wn8t�y}zt
�d
t|��WYd}~n
d}~00dd�|
D�D�]�tj���}t�fd
d�tjD���rZ�q*tj�|�}
|
d}z|
d}Wnt�y�d}Yn0t�dd��|�jdv�r�t�|	��jd|<|�jdv�r�t�|	��jd|<|�j|v�rt�|	��j||<|�j|v�r*t�|	��j||<�q*�j�|�zN||}|j|_||_|j�rddnd|_|j�rzd|n||_	d|_|WSt
�y�Yq�0q�|�d��s6d|}||v�r6||}|�s�tj� |j��s�t
�!d|�"d��|j|_||_|j�rdnd|_|j�r&d|n||_	d|_|Sd�#|�}d|v�rht$�%|��rh�j&||||d�S|�'d�#|��S)z�Search library and various *_plugins paths in order to find the file.
        This was behavior prior to the existence of collections.
        F�ansible.builtinry�ansible.builtin.Tc3s0|](}|j�jvrtj�t|j��r|VqdSrW)r9r�r8r;rr�rpr)r/�	<genexpr>�r1z3PluginLoader._find_plugin_legacy.<locals>.<genexpr>z	trying %sc3s|]}tj��|�VqdSrW)r8r9r=r�)rAr)r/r��r1z Error accessing plugin paths: %sNcss,|]$}tj�|�r|�d�st|�VqdS)s__init__.pyN)r8r9r�r�rr�r)r)r/r��r1c3s|]}��|�VqdSrW)r�)r,r�)�	full_pathr)r/r��r1rrr5r6�_z�%s is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.zansible.builtin.{0}rs)r�r�r(r�z.{0} is not eligible for last-chance resolution)(rmr�rHr�r9rfrgrXrhrn�KeyErrorr�rr?r�rcrr8�listdir�OSErrorr@rrF�anyr�r��splitext�
IndexErrorrVr��addru�islinkri�lstripr~rrtr�r�)rYr-r(r�r�r�Z
pull_cacher�r9rXZ
full_paths�er�Z	splitname�	base_namer�Z
alias_nameZcandidate_fqcrr))rArrYr/r��s�
(


�
z PluginLoader._find_plugin_legacyc
Cs^z|j||d�duWStyX}z,t|t�r0�t�d�t|���WYd}~n
d}~00dS)z& Checks if a plugin named name exists �r�Nzhas_plugin error: {0})r�rIr*r
r?r�r~r)rYr-r�r�r)r)r/�
has_plugins
zPluginLoader.has_pluginc	Cs�|�d�r|}nd�|j|g�}|tjvr4tj|St���vt�dt�t	j
�t|�t|��}t	j
�
|�}|tj|<z|j�|�Wnty�tj|=�Yn0Wd�n1s�0Y|S)N�ansible_collections.rs�ignore)rur=r�rPrQ�warnings�catch_warnings�simplefilter�RuntimeWarning�	importlib�util�spec_from_file_locationr�module_from_specrT�exec_modulerI)rYr-r9r��specr�r)r)r/�_load_module_source's 




&z PluginLoader._load_module_sourcecCs�t|d|�t|d|�t|d|p$g�g}|r:|�|�|rR|�|ddd��|sdtd|����t|d|�t|d|d�dS)	N�_original_pathZ
_load_nameZ_redirected_namesrqzMissing FQCN for plugin source Zansible_aliases�ansible_namer)rKrr�r
)rYr.r-r9�redirected_namesrm�namesr)r)r/�_update_objectFs
zPluginLoader._update_objectcOs|j|g|�Ri|��jSrW)�get_with_contextr')rYr-�args�kwargsr)r)r/rHYszPluginLoader.getc
Ost|�r|��}d}|�dd�}|�dd�}||jvr@|j|}|j||d�}|jrZ|jsdtd|�S|j}d|vr�d�	|j
|f�}|j}|j}	|jp�g}
|	|j
vr�|�||	�|j
|	<d}|�||j
|	|	�t|j
|	|j�}|j�r>t|j|jgd�}zt||j�}
Wnt�y&td|�YS0t||
��s>td|�S|j|j||j|	||d	�|�sz<t�|�}|�|||	|
|�|j|g|�Ri|��|}Wndt�y�}zJd
|jdv�r�t� d|t!|�f�td|�WYd}~S�WYd}~n
d}~00|�|||	|
|�t||�S)
z9 instantiates a plugin of the given name using arguments T�
class_onlyFr�Nr
rs��fromlist��found_in_cacher$ZabstractrzHReturning not found on "%s" as it has unimplemented abstract methods; %s)"r#Z
_strip_unsafe�popr�r�rmrfr&rwr=rhrgr`r�rr�rOr�r�r�r��AttributeError�
issubclass�_display_plugin_loadr�r'�__new__r rZ�	TypeErrorr"r?�vr)rYr-r"r#r(r$r�r(r�r9rr.r��plugin_class�instancerr)r)r/r!\sV







zPluginLoader.get_with_contextcCs^tjrZd|tj�|�|f}t|�dkr:d||�|�f}|sB|rPd|||f}t�|�dS)zd formats data to display debug info for plugin loading, also avoids processing unless really needed zLoading %s '%s' from %srz%s (searched paths: %s)z%%s (found_in_cache=%s, class_only=%s)N)	r�Z
DEFAULT_DEBUGr8r9rFr�r�r?r�)rYr�r-Zsearched_pathsr9r(r$r�r)r)r/r,�sz!PluginLoader._display_plugin_loadcosH|�dd�}|�dd�}|�dd�}|r4|r4td��g}d}t�}|��D]D}	t�ttj�|	jd���}
|	j	sx|�
|
�|�t|
tjj
d��qJt�}|D�]�}tj�|�d	}
tj�
|
�}|t|jvr�t�d
|�q�|dks�|dk�r|jd
k�rt�d|�q�|�r(||v�r(t�d|�q�|�|�|�r@|Vq�||jv�r�|jdv�rnd�tt|��|�}n|}z|�||�}WnHt�y�}z.t�d|t|�f�WYd}~q�WYd}~n
d}~00||j|<d}n
|j|}|�|||�zt||j�}WnHt �yL}z.t�d|t|�f�WYd}~q�WYd}~n
d}~00|j!�r�t"|j|j!gd�}zt||j!�}Wnt �y�Yq�Yn0t#||��s�q�|j$|j||j%|||d�|�sz||i|��}Wn<t&�y}z"t�d|t|�f�WYd}~n
d}~00||v�r |}n
d|��}|j'||||d�|Vq�dS)a
        Iterate through all plugins of this type, in configured paths (no collections)

        A plugin loader is initialized with a specific type.  This function is an iterator returning
        all of the plugins of that type to the caller.

        :kwarg path_only: If this is set to True, then we return the paths to where the plugins reside
            instead of an instance of the plugin.  This conflicts with class_only and both should
            not be set.
        :kwarg class_only: If this is set to True then we return the python class which implements
            a plugin rather than an instance of the plugin.  This conflicts with path_only and both
            should not be set.
        :kwarg _dedupe: By default, we only return one plugin per plugin name.  Deduplication happens
            in the same way as the :meth:`get` and :meth:`find_plugin` methods resolve which plugin
            should take precedence.  If this is set to False, then we return all of the plugins
            found, including those with duplicate names.  In the case of duplicates, the order in
            which they are returned is the one that would take precedence first, followed by the
            others  in decreasing precedence order.  This should only be used by subclasses which
            want to manage their own deduplication of the plugins.
        :*args: Any extra arguments are passed to each plugin when it is instantiated.
        :**kwargs: Any extra keyword arguments are passed to each plugin when it is instantiated.
        �_dedupeT�	path_onlyFr$�HDo not set both path_only and class_only when calling PluginLoader.all()z*.pyr�rz+'%s' skipped due to a defined plugin filterrZ�base�ansible.plugins.cachez!'%s' skipped due to reserved namez'%s' skipped as duplicate)�filter�testz{0}_{1}z%Skipping plugin (%s), cannot load: %sNz2Skipping plugin (%s) as it seems to be invalid: %sr%r'z5Skipping plugin (%s) as it seems to be incomplete: %sr��rm)(r)r
r�r�r�rr8r9r=rX�updater�r�rFrr�r�r?r�rr�r�r~�abs�hashrrIr@rr�rOr�r*r�r�r+r,r�r.r )rYr"r#Zdeduper3r$Zall_matchesr(Zlegacy_excluding_builtinr��matchesZloaded_modulesr9r-rFr�r�rr.r0�fqcnr)r)r/rJ�s�"


"

"
,

zPluginLoader.all)NN)T)T)T)F)N)F)ryFFN)ryFFN)FFN)N)NN)NN)"rRr[r\�__doc__rZr�r�r�r�r�r�r�r�r�r�r�r�r�r>r�r�r�r�r]r�r�r�__contains__rr rHr!r,rJr)r)r)r/r+�s@
#

	

5



m

�
I
k

H

r+csleZdZdZd�fdd�	Z�fdd�Zdd	d
�Zedd��Zd
d�Z	�fdd�Z
dd�Z�fdd�Z�Z
S)�Jinja2Loadera

    PluginLoader optimized for Jinja2 plugins

    The filter and test plugins are Jinja2 plugins encapsulated inside of our plugin format.
    We need to do a few things differently in the base class because of file == plugin
    assumptions and dedupe logic.
    Ncs,tt|�j||||||d�||_i|_dS)N�r�r�)�superrArZ�_plugin_wrapper_type�_cached_non_collection_wrappers)rYr�r�r�r<Zplugin_wrapper_typer�r���	__class__r)r/rZ<szJinja2Loader.__init__cstt|���i|_dSrW)rCrAr�rErprFr)r/r�AszJinja2Loader._clear_cachesryFcCstd��dS)Nz,find_plugin is not supported on Jinja2Loader)�NotImplementedError)rYr-r�r�r�r�r)r)r/r�EszJinja2Loader.find_plugincCst|j�dS)N�s)rr�rpr)r)r/�method_map_nameHszJinja2Loader.method_map_namec
Csng}d�d|d|j|g�}z6||jvr8|�||�|j|<|j|}t||j�}Wn:ty�}z"td||t|�f��WYd}~n
d}~00|�}	|	dur�td||f��zt|	|j	�}
|
��
�}WnDt�y}z*t�d|jt
|�|f�|WYd}~Sd}~00|D]Z\}}
d�||f�}d�||f�}|�|
�}||v�rJ�q|j||||d�|�|��q|S)NrsZansible_collections�pluginszFailed to load %s for %s: %szCould not find %s.%sz9Ignoring %s plugins in '%s' as it seems to be invalid: %rr9)r=r�r�rrOr�rIrrrJr3r?r@rrDr r)rYr�rBr-rKr�r�r.r�plugin_impl�
method_map�
plugin_map�	func_name�funcr�Zfull�pluginr)r)r/�get_contained_pluginsLs6

,

z"Jinja2Loader.get_contained_pluginsc$s�|�dd�|�dd�t�}|�d�}|j|i|��|j�|�}r�d|_||_|j|_	|j
�d�rldnd|_|j
|_
t||�Sd}t|�\}}t�}	||	vr�td	|d
��|	�|�t�||j�}
|
s�td�|���zt|
j�}Wn:t�y"}z td�|t|����WYd}~n
d}~00|�d
i��|ji��|i�}
|
�d�}|�r�|�d�}|�d�}|�d�}|�s�d�|j|�}tj||||
jd�|
�d�}|�r�|�d�}|�d�}|�d�}|�s�d�|j|�}tj||||
jdd�}t|��|
�dd�}|�rxt� |��s>td|
j�d|
j�d|
j!�d|�d�	��t||
jd�\}}t�"d�|j|
j|
j!|��|}q��qxq�zt#|
j$�}Wn2t%�y�}ztt|���WYd}~n
d}~00|
j}|
j&�r�d�||
j&�}�z@t'j(|j)|dd �D�]$\}}}|�r�q�z:t*t+|�j,|g|�Ri|��}t-|j.|j/�}|��0�}WnRt1�y�}z8t�2d!|j�d"|�d#|���WYd}~�q�WYd}~n
d}~00|D]z\}}d�3||f�} d$|
j�d%|j�d|
j&�d|��}!||| fv�r�|�4|�}|�r�|j5}|j6||!|j.j| d&��q�q��q�Wn�t�yP}"ztt|"�d
|"d'��WYd}"~"n~d}"~"0ttf�yh�Yn^t1�y�}#zDt�2d(�t|#���t�"d)�t7���tt|#�d
|#d'��WYd}#~#n
d}#~#00t||�S)*Nr$Fr�rrTr�r�ryz*recursive collection redirect found for %rrzinvalid plugin name: {0}zInvalid plugin FQCN ({0}): {1}r�r�rxrjrkz{0} "{1}" is deprecated)r|r{r}r�z{0} "{1}" has been removed)r|r{r}r�r�r�r�rsr�r�)r�z&redirecting (type: {0}) {1}.{2} to {3}r�)�prefixz	Skipping z plugins in z$'; an error occurred while loading: rz	.plugins.r9)Zorig_excz>An unexpected error occurred during Jinja2 plugin loading: {0}z2Unexpected error during Jinja2 plugin loading: {0})8r)r]r��_ensure_non_collection_wrappersrErHrmrgrrfrrurhrnr&�get_fqcr_and_namer�r
rrZtry_parse_fqcrr�rr~rr�r�rr?rir�rrtr�Zvvvrr�r�r��pkgutil�iter_modules�__path__rCrAr!rOr'rJr3rIr@r=rDr(r r)$rYr-r"r#�contextZknown_pluginrQr�Zleaf_key�seenr��tsrZ
routing_entryZdeprecation_entryrxrjrkZtombstone_entryZexc_msgr�Znext_keyr�Z
parent_prefixZdummyZmodule_name�ispkgrLrMrNrOrPr�Zsrc_nameZaprer�rFr)r/r!rs�


*








�"�" $"
&(zJinja2Loader.get_with_contextcos�|�dd�|�dd�}|�dd�}|r4|r4td��|j|i|��|rddd�|j��D�EdHndd�|j��D�EdHdS)	Nr2r3Fr$r4css|]}|jVqdSrW)r�r,�wr)r)r/r�r1z#Jinja2Loader.all.<locals>.<genexpr>css|]
}|VqdSrWr)r]r)r)r/r�r1)r)r
rTrE�values)rYr"r#r3r$r)r)r/rJ�szJinja2Loader.allcs�|jr
dStt|�j|i|��D�]�}|j�d�}t||j�}z
|�}WnLty�}z4t	�
d|jt|j
�|f�WYd}~q WYd}~n
d}~00|��D�] }d|vr�t	�|�d|j
�d��q�|t|jvr�t	�d|�q�|�||�}	|}
|j�d�dk�r"d�|j�d�dd��nd}|�|��s@|�d|��}
|j|	||j
|
d	�||
h}|�rr|�d|���|D]H}
|j�|
�}�r�t	�d
|
�d|j
�d|j
�d
���qv|	|j|
<�qvq�q dS)Nr�z9Skipping %s plugins in '%s' as it seems to be invalid: %rrsz skipped in z.; Jinja plugin short names may not contain "."z)%s skipped due to a defined plugin filter�ryr9z
Jinja plugin z from z" skipped; shadowed by plugin from �))rErCrArJrrurOrJrIr?�vvvvr�rr�keysr�r�r�rD�countr=rvr rrH)rYr"r#Zp_map�
is_builtinZplugins_listrKrZplugin_name�wrapperr>r�Ztarget_namesZtarget_nameZexisting_pluginrFr)r/rTsB
"0�
z,Jinja2Loader._ensure_non_collection_wrappers)NN)ryFFN)rRr[r\r?rZr�r�r�rJrRr!rJrT�
__classcell__r)r)rFr/rA4s

&rAr�cCs4d|vr|}|d|}n|�d�d}|}||fS)Nrsrq)rv)r�r�r-Zfqcrr)r)r/rU8srUcCs�tt�}d}tjdurd}n
tj}d}tj�|��rpt|d��n}zt|�	��}WnLt
y�}z4t�d�
|t|���|WYd}~Wd�Sd}~00Wd�n1s�0Yz|d}Wn&ty�t�d�
|��|YS0t|�}|��}|dk�r^zt|�d	|d
��|d<Wn(t�yNt�d�
|��|YS0|d|d
<nt�d�
|��n|�r�t�d�
|��d|dv�r�td�
t|����|S)NFz/etc/ansible/plugin_filters.ymlT�rbz;The plugin filter file, {0} was not parsable. Skipping: {1}Zfilter_versionz2The plugin filter file, {0} was invalid. Skipping.z1.0zmodule_rejectlist)Zmodule_blacklist�ansible.moduleszWUnable to parse the plugin filter file {0} as module_blacklist is not a list. Skipping.�ansible.plugins.actionz^The plugin filter file, {0} was a version not recognized by this version of Ansible. Skipping.z5The plugin filter file, {0} does not exist. Skipping.�statz�The stat module was specified in the module blacklist file, {0}, but Ansible will not function without the stat module.  Please remove stat from the blacklist.)r�	frozensetr�ZPLUGIN_FILTERS_CFGr8r9r��openr�readrIr?r@r~rr�striprHr.r
r)�filtersZuser_setZ
filter_cfgr�Zfilter_datarr|r)r)r/�_load_plugin_filterCsZ
�F�

�
���rqc
Cs�t�td�||���t|�}zRt|�dd�t�sntj	�
d�}d�|t�}|dkr^t�|�n|dkrnt|��WnHt
y��Yn6ty�}zt�d�||��WYd}~n
d}~00dS)	NzLoading collection {0} from {1}Zrequires_ansibleryZ'COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCHz3Collection {0} does not support Ansible version {1}r@�errorzQError parsing collection metadata requires_ansible value from collection {0}: {1})r?rbrr~r�(_does_collection_support_ansible_versionrH�ansible_versionr�r�Zget_config_valuer@rr
rI)r}Zcollection_pathr�Zmismatch_behavior�messager�r)r)r/�_on_collection_load_handler}srvcCs6|sdStst�d�dSt|�}t|�j}|�|�S)NTz_packaging Python module unavailable; unable to validate collection Ansible version requirements)r$r?r@r%Zbase_version�contains)Zrequirement_stringrt�ssZbase_ansible_versionr)r)r/rs�s

rscCs<tjrt�d�dSttjtj�}|��tj	t
7_	dS)Nz3AnsibleCollectionFinder has already been configured)rZcollection_finderr�warnrr�ZCOLLECTIONS_PATHSZCOLLECTIONS_SCAN_SYS_PATH�_installZon_collection_loadrv)�finderr)r)r/�_configure_collection_loader�s
r|ZModuleDocFragmentzansible.plugins.doc_fragmentsZ
doc_fragmentsZActionModulerjZaction_pluginsZ
ActionBase)r�ZCacheModuler6Z
cache_pluginsZCallbackModulezansible.plugins.callbackZcallback_pluginsZ
Connectionzansible.plugins.connectionZconnection_pluginsZparamikoZparamiko_sshZConnectionBaserBZShellModulezansible.plugins.shellZ
shell_pluginsryriZlibraryzansible.module_utilsZmodule_utilsZLookupModulezansible.plugins.lookupZlookup_pluginsZ
LookupBaseZFilterModulezansible.plugins.filterZfilter_pluginsZ
TestModulezansible.plugins.testZtest_pluginsZStrategyModulezansible.plugins.strategyZstrategy_pluginsZStrategyBaseZTerminalModulezansible.plugins.terminalZterminal_pluginsZTerminalBaseZ
VarsModulezansible.plugins.varsZvars_pluginsZCliconfzansible.plugins.cliconfZcliconf_pluginsZCliconfBaseZNetconfzansible.plugins.netconfZnetconf_pluginsZNetconfBaseZInventoryModulezansible.plugins.inventoryZinventory_pluginsZHttpApizansible.plugins.httpapiZhttpapi_pluginsZHttpApiBaseZBecomeModulezansible.plugins.becomeZbecome_plugins)NN)r�){Z
__future__rrrr�Z
__metaclass__r�r8Zos.pathrVrPr�collectionsrr�	tracebackrr7r	r8r
Zansiblerrtrr�Zansible.errorsr
rrrZansible.module_utils._textrrrZ%ansible.module_utils.compat.importlibrZansible.module_utils.sixrZansible.parsing.utils.yamlrZansible.parsing.yaml.loaderrZansible.pluginsrrrrZansible.utils.collection_loaderrrZ2ansible.utils.collection_loader._collection_finderrrZansible.utils.displayr Zansible.utils.plugin_docsr!r"Zansible.utils.unsafe_proxyr#Zpackaging.specifiersr$Zpackaging.versionr%r��importlib.utilrr?r&r4rCrMrUr'rVr]r+rArUrqrvrsr|r�ZDOC_FRAGMENT_PLUGIN_PATHr�ZDEFAULT_ACTION_PLUGIN_PATHZ
action_loaderZDEFAULT_CACHE_PLUGIN_PATHZcache_loaderZDEFAULT_CALLBACK_PLUGIN_PATHZcallback_loaderZDEFAULT_CONNECTION_PLUGIN_PATHZconnection_loaderrGZDEFAULT_MODULE_PATHZ
module_loaderZDEFAULT_MODULE_UTILS_PATHZmodule_utils_loaderZps_module_utils_loaderZDEFAULT_LOOKUP_PLUGIN_PATHZ
lookup_loaderZDEFAULT_FILTER_PLUGIN_PATHZ
filter_loaderZDEFAULT_TEST_PLUGIN_PATHZtest_loaderZDEFAULT_STRATEGY_PLUGIN_PATHZstrategy_loaderZDEFAULT_TERMINAL_PLUGIN_PATHZterminal_loaderZDEFAULT_VARS_PLUGIN_PATHZvars_loaderZDEFAULT_CLICONF_PLUGIN_PATHZcliconf_loaderZDEFAULT_NETCONF_PLUGIN_PATHZnetconf_loaderZDEFAULT_INVENTORY_PLUGIN_PATHZinventory_loaderZDEFAULT_HTTPAPI_PLUGIN_PATHZhttpapi_loaderZBECOME_PLUGIN_PATHZ
become_loaderr)r)r)r/�<module>sx

!Rr
:�����	���	������������