관리-도구
편집 파일: loader.cpython-39.opt-1.pyc
a �����)g����������������������@���s���d�dl�mZmZmZ�eZd�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlZd�dlm Z mZ�d�dlmZ�ddlmZ�ddlmZ�d�dlmZ�d�d lmZ�d�d lmZmZmZmZ�d�dlm Z m!Z!m"Z"�d�dl#m$Z$�d�d l%m&Z&�d�dl'm(Z(�d�dl)m*Z*�d�dl+m,Z,m-Z-m.Z.m/Z/�d�dl0m1Z1m2Z2�d�dl3m4Z4m5Z5�d�dl6m7Z7�d�dl8m9Z9m:Z:�d�dl;m<Z<�zd�dl=m>Z>�d�dl?m@Z@�W�n�eA�y����dZ>dZ@Y�n0�d�dlBZCe7��ZDedddg�ZEdd��ZFdd��ZGdzdd �ZHd!d"��ZIG�d#d$��d$eJ�ZKG�d%d&��d&eJ�ZLG�d'd(��d(�ZMG�d)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_contextc�������������������C���s���dd��t������D��S�)Nc�����������������S���s"���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_loaders7���s����r4���c�����������������C���s|���t�j�t|�dd��}t�j�|�rft��D�]<\}}|jr&t�j�|t|j��}t�j�|�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����rC���c�����������������C���s����|�s|d}�|rtt�|t�r|tj�|�}zt�|�}W�n�tyF���d�}Y�n0�|d�u�r|t���D�]}||j v�rX|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*���r���r8���r9����basename�shell_loader�get� Exception�allZCOMPATIBLE_SHELLSZSHELL_FAMILYr ����setattr)Z shell_typerE���Zshell_filename�shellr)���r)���r/����get_shell_pluginH���s*���� rM���c�����������������C���s0���t�tjt�d|���}|D�]}|j|dd��qd�S�)Nz %s_loaderT)�with_subdir)�getattr�sys�modules�__name__r>���)Zwhich_loader�paths�loaderr9���r)���r)���r/����add_dirs_to_loaderi���s����rU���c�������������������@���s���e�Zd�Zdd��ZdS�)�PluginPathContextc�����������������C���s���||�_�||�_d�S��N)r9����internal)�selfr9���rX���r)���r)���r/����__init__q���s����zPluginPathContext.__init__N)rR���� __module__�__qualname__rZ���r)���r)���r)���r/���rV���p���s���rV���c�������������������@���s@���e�Zd�Zdd��Zedd���Zdd��Zdd��Zd d ��Zdd��Z d S�)�PluginLoadContextc�����������������C���sj���d�|�_�g�|�_g�|�_g�|�_g�|�_d�|�_d�|�_d�|�_d�|�_d�|�_ d|�_ d�|�_d�|�_g�|�_ d|�_d�|�_d�|�_d�S��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�rY���r)���r)���r/���rZ���w���s"����zPluginLoadContext.__init__c�����������������C���sf���|�j�s d�S�|�js`|�jd�}t�|�r<|�d�r<|�d�d�}|�jrZt�|�sZ|�jd�|�}||�_|�jS�)N����ansible.legacy.�.)rm���rn���r`���r���� is_valid_fqcr� startswith�splitrh���)rY���Zfinal_pluginr)���r)���r/���� resolved_fqcn����s���� zPluginLoadContext.resolved_fqcnc�����������������C���s����|s|�S�|��dd��pd}|��dd��}|��dd��}|d�ur<d�}d�||rJdnd|�}tj||||d��d|�_|rt||�_|r~||�_|�j�|��|�S�) N�warning_text��rj���rk���z{0} has been deprecated.{1}{2}� )�date�version�collection_nameT)rH����formatr?���ri���rj���rk���rl����append)rY���r-����deprecationr}���rx���rj���rk���r)���r)���r/����record_deprecation����s ����z$PluginLoadContext.record_deprecationc�����������������C���s.���d�|�_�||�_||�_||�_||�_d|�_||�_|�S�)NT)rd���rg���rf���rh���re���rm���ro���)rY���Z resolved_name� resolved_pathZresolved_collectionre���ro���r)���r)���r/����resolve����s����zPluginLoadContext.resolvec�����������������C���s ���||�_�d�|�j|�|�_d|�_|�S�)Nz+pending redirect resolution from {0} to {1}F)rd���r~���r_���re���rm���)rY���Z redirect_namer)���r)���r/����redirect����s����zPluginLoadContext.redirectc�����������������C���s���d�|�_�||�_d|�_|�S�r^���)rd���re���rm���)rY���re���r)���r)���r/����nope����s����zPluginLoadContext.nopeN) rR���r[���r\���rZ����propertyrw���r����r����r����r����r)���r)���r)���r/���r]���v���s��� r]���c�������������������@���s��e�Zd�ZdZd<dd�Zedd���Zdd��Zd d ��Zdd��Z d d��Z dd��Zdd��Zdd��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. Nc�����������������C���s����|d�u�ri�n|}||�_�||�_||�_||�_||�_|rDt|t�sD|g}n|sLg�}||�_|tvrbi�t|<�|t vrrd�t |<�|t vr�tt�t |<�g�|�_ t|�|�_t |�|�_t |�|�_t��|�_d�S�rW���)� class_name� base_class�packager<����aliasesr*����list�configr���r���r���r����dict�_extra_dirs� _module_cache�_paths�_plugin_path_cache�set�_searched_paths)rY���r����r����r����r<���r�����required_base_classr)���r)���r/���rZ�������s,���� zPluginLoader.__init__c�����������������C���s���t��|�j�S�rW���)r���� legacy_plugin_dir_to_plugin_typer<���rp���r)���r)���r/����type����s����zPluginLoader.typec�����������������C���s���d��|�j�S�)NzPluginLoader(type={0}))r~���r����rp���r)���r)���r/����__repr__����s����zPluginLoader.__repr__c�����������������C���s`���t�jrd�|�_nNi�t|�j<�d�t|�j<�tt�t|�j<�t|�j�|�_ t|�j�|�_t|�j�|�_ t��|�_d�S�rW���) �CZOLD_PLUGIN_CACHE_CLEARINGr����r���r����r���r���r����r���r����r����r����r����rp���r)���r)���r/���� _clear_caches����s���� zPluginLoader._clear_cachesc�����������������C���s����|��d�}|��d�}|��d�}|��d�}|��d�}|��d�}|��d�t|<�|��d�t|<�|��||||||��|��d g��|�_|��d t���|�_dS�)z Deserializer. r����r����r����r<���r����r����r���r���r����r����N)rH���r���r���rZ���r����r����r����)rY����datar����r����r����r<���r����r����r)���r)���r/����__setstate__ ��s���� zPluginLoader.__setstate__c�����������������C���s8���t�|�j|�j|�j|�j|�j|�j|�j|�jt |�j�t |�j�d� S�)z Serializer. ) r����r����r����r����r<���r����r����r����r���r���)r����r����r����r����r����r<���r����r����r����r���r���rp���r)���r)���r/����__getstate__��s�����zPluginLoader.__getstate__c�����������������C���s,���g�}|D�]}||vr|��|��qtj�|�S�)z; Returns a string suitable for printing of the search path )r���r8����pathsepr=���)rY���rS����ret�ir)���r)���r/����format_paths/��s ����zPluginLoader.format_pathsc�����������������C���s���|���|�jdd��S�)NF��subdirs)r����� _get_pathsrp���r)���r)���r/����print_paths9��s����zPluginLoader.print_pathsc�����������������C���sR���g�}|��|��tj|dd�D�]0\}}}d|v�r|D�]}|��tj�||���q2q|S�)NT)�followlinksz__init__.py)r���r8����walkr9���r=���)rY����dir�results�rootr�����files�xr)���r)���r/����_all_directories<��s���� zPluginLoader._all_directoriesTc�����������������C���sv���|�j�s g�S�t|�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_pathrs���r���Nr5���r6���)r�����hasattr� __import__rv���rO���r���r8���r9����dirname�__file__r����r����)rY���r�����m�partsZ parent_modr)���r)���r/����_get_package_pathsE��s���� zPluginLoader._get_package_pathsc�����������������C���s����|�j�dur|�j�S�dd��|�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 Nc�����������������S���s���g�|�]}t�|d���qS�)F�rV����r,����pr)���r)���r/���r0���]��r1���z8PluginLoader._get_paths_with_context.<locals>.<listcomp>z%s/*z%s/*/*r5���r6���Fc�����������������S���s���g�|�]}t�|d���qS�)Tr����r����r)���r)���r/���r0���q��r1���r����c�����������������S���s���|�j��d�S�)Nz/windows)r9����endswith)r����r)���r)���r/����<lambda>���r1���z6PluginLoader._get_paths_with_context.<locals>.<lambda>��key)r����r����r����r8���r9����abspathr:����globr���r;���r���rV����extendr�����sort)rY���r����r����r9����contents�cr)���r)���r/����_get_paths_with_contextT��s&���� z$PluginLoader._get_paths_with_contextc�����������������C���s���|�j�|d�}dd��|D��S�)z1 Return a list of paths to search for plugins in r����c�����������������S���s���g�|�] }|j��qS�r)���)r9���)r,����path_with_contextr)���r)���r/���r0������r1���z+PluginLoader._get_paths.<locals>.<listcomp>)r����)rY���r����Zpaths_with_contextr)���r)���r/���r�������s����zPluginLoader._get_pathsc�����������������C���s����|�j�r�t|�j��}|tjv�r�tj�||�s�tt|dd�|d����}|r�t ||t |dkd��d|v�r�t|d�t�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����r���r����ZCONFIGURABLE_PLUGINSr����Zhas_configuration_definitionr���rO���Zget_single_datar!���r����r*���r����Z+initialize_plugin_configuration_definitionsr?����debug)rY���r-���r����r9���� type_nameZdstringr)���r)���r/����_load_config_defs���s���� zPluginLoader._load_config_defsFc�����������������C���sX���t�j�|�}|durT|r(t�j�||�j�}||�jvrT|�j�|��|�����t� d|���dS�)z1 Adds an additional directory to the search path NzAdded %s to loader search path) r8���r9����realpathr=���r<���r����r���r����r?���r����)rY���Z directoryrN���r)���r)���r/���r>������s���� zPluginLoader.add_directoryc�����������������C���s����t�|j�}|sd�S�zt�|jd�|����W�n�ty<���Y�n0�t|dd��}|sRd�S�|jrld�|j|jg�}n|j}|�di���|i���||�d��}|s�|�di���|i���|d��}|S�)Nz.plugins.{0}Z_collection_metars����plugin_routing) r���Z n_python_collection_package_namer~����ImportErrorrO���r����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�������������� ���C���s���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�}W�n&�t�y����|�d� |j���Y�S�0�tj �!|j"�}tj �#||�}tj �$|��r"|�%|t&|�|jd� ||j�|�S�|�r@|�d� t&|�|j��S�dd��t'�(tj �#||�d��D��}|�s||�d � ||j��S�t)|�}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����� tombstonerj���rk���rx���ry���z{0} has been removed.{1}{2}rz���T)�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}rQ���ro����strictr6����{0}.{1}zPython package {0} not foundz found exact match for {0} in {1}zno match for {0} in {1}c�����������������S���s(���g�|�] }t�j�|�r|�tj�s|�qS�r)���)r8���r9����isfiler����r�����MODULE_IGNORE_EXTS�r,����fr)���r)���r/���r0���0��s����z0PluginLoader._find_fq_plugin.<locals>.<listcomp>z.*z+failed fuzzy extension match for {0} in {1}r���zDFound several possible candidates for the plugin but using first: %s�,r���z*found fuzzy extension match for {0} in {1}),rm���r���r����r<���Z from_fqcrr����rH���r����� collectionr~���r?����get_deprecation_messagerj���rk���re���r���rt���r ���Zvvr`���r���r����r����r���r�����n_python_package_namerP���rQ���r���r����r����r8���r9���r����r����r=����existsr����r���r����Ziglob�sorted�lenr����)rY����fq_namer����r(����ignore_deprecatedr����r����Zrouting_metadataro���r����r����rj���rk���rx���Zremoved_msgr����Z n_resource� full_name�pkgZpkg_pathZn_resource_pathZfound_filesr)���r)���r/����_find_fq_plugin���s����� �� ���zPluginLoader._find_fq_pluginry���c�����������������C���s(���|���|||||�}|jr$|jr$|jS�dS�)z Find a plugin named name N)�find_plugin_with_contextrm���rf���)rY���r-����mod_typer����� check_aliases�collection_list�resultr)���r)���r/����find_plugin@��s����zPluginLoader.find_pluginc�����������������C���s|���t���}||_|�j||||||d�}|jr^|j|jv�rHtd�|j|j���|j}d|_|}qq^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_steprd���r`���r���r~���ra���r?���r@���)rY���r-���r����r����r����r����r(���r����r)���r)���r/���r����H��s���� z%PluginLoader.find_plugin_with_contextc��������������������s���|st�d��|j�����d|_��t|�j�v�r<d����|_|S�|rF|}n|�jrRd}nd}t � ���sf|�rڈ��d��s�d��v�s~|s���g}n��fdd �|D��}|D��]} z�|j�| ��| �d �r�|�� ���d�||||�}n2|�j| |||d�}|j�r| |jv�r|j�| ��|j�s|j�r |W���S�W�q��tttf�y>�����Y�q��t�yn�} �z|j�| ��W�Y�d�} ~ q�d�} ~ 0��t�y��}�z|j�t|���W�Y�d�}~q�d�}~0�0�q�|j�r�tjd ���d�|j��d��d����|_|S�|�� ��||||�S�)NzA PluginLoadContext is requiredFz#{0} matched a defined plugin filterz.pyry���ZAnsiblers���c��������������������s���g�|�]}d���|����qS�)r����)r~���)r,���r�����r-���r)���r/���r0������r1���z5PluginLoader._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`���r���rm����_PLUGIN_FILTERSr����r~���re���r����r���rt���ru���rc����_find_plugin_legacy�removeprefixr����rd���r���r���r���r����rb���rI���ra���r���r?���r����r=���)rY���r-���r����r����r����r����r(����suffixZ candidatesZcandidate_nameZie�exr)���r����r/���r����f��sR���� � � (z!PluginLoader._resolve_plugin_stepc��������������������sx��d|_�|r�j�||�}�j|�}zF||�}|j|_||_|jrDdnd|_|jrXd|�n||_ d|_�|W�S��t yz���Y�n0��fdd�����D��D��]}|j}t|���t �d|���|j�|��|j} z��fd d�t����D��} W�n8�t�y�}�zt �d t|����W�Y�d}~n d}~0�0�dd��| D��D��]�tj���}t�fd d�tjD����rZ�q*tj�|�} | d�}z| d�}W�n�t�y����d}Y�n0�t�dd��|�jd�v�r�t�| ��jd�|<�|�jd�v�r�t�| ��jd�|<�|�j|�v�rt�| ��j|�|<�|�j|�v�r*t�| ��j|�|<��q*�j�|��zN||�}|j|_||_|j�rddnd|_|j�rzd|�n||_ d|_�|W���S��t �y����Y�q�0�q�|�d��s6d|�}||v��r6||�}|�s�tj� |j��s�t �!d|�"d����|j|_||_|j�rdnd|_|j�r&d|�n||_ d|_�|S�d�#|�}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.Tc�����������������3���s0���|�](}|j���jvrtj��t|j���r|V��qd�S�rW���)r9���r����r8���r;���r���r����rp���r)���r/���� <genexpr>���r1���z3PluginLoader._find_plugin_legacy.<locals>.<genexpr>z trying %sc�����������������3���s���|�]}t�j���|�V��qd�S�rW���)r8���r9���r=���r����)rA���r)���r/���r�������r1���z Error accessing plugin paths: %sNc�����������������s���s,���|�]$}t�j�|�r|�d��st|�V��qdS�)s���__init__.pyN)r8���r9���r����r����r���r����r)���r)���r/���r�������r1���c�����������������3���s���|�]}����|�V��qd�S�rW���)r����)r,���r����)� full_pathr)���r/���r�������r1���r���r���r5���r6����_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)(rm���r����rH���r����r9���rf���rg���rX���rh���rn����KeyErrorr����r���r?���r����rc���r���r8����listdir�OSErrorr@���r���rF����anyr����r�����splitext� IndexErrorrV���r�����addru����islinkri����lstripr~���r���rt���r����r����)rY���r-���r(���r����r����r����Z pull_cacher����r9���rX���Z full_paths�er����Z splitname� base_namer����Z alias_nameZcandidate_fqcrr)���)rA���r���rY���r/���r�������s����� ( � z PluginLoader._find_plugin_legacyc�������������� ���C���s^���z|�j�||d�duW�S��tyX�}�z,t|t�r0��t�d�t|����W�Y�d}~n d}~0�0�dS�)z& Checks if a plugin named name exists �r����Nzhas_plugin error: {0})r����rI���r*���r ���r?���r����r~���r���)rY���r-���r����r����r)���r)���r/���� has_plugin��s���� zPluginLoader.has_pluginc�������������� ���C���s����|��d�r|}nd�|�j|g�}|tjv�r4tj|�S�t����v�t�dt��t j �t|�t|��}t j � |�}|tj|<�z|j�|��W�n�ty����tj|=���Y�n0�W�d�����n1�s�0����Y��|S�)N�ansible_collections.rs����ignore)ru���r=���r����rP���rQ����warnings�catch_warnings�simplefilter�RuntimeWarning� importlib�util�spec_from_file_locationr����module_from_specrT����exec_modulerI���)rY���r-���r9���r�����specr����r)���r)���r/����_load_module_source'��s ���� &z PluginLoader._load_module_sourcec�����������������C���s����t�|d|��t�|d|��t�|d|p$g���g�}|r:|�|��|rR|�|d�d�d����|sdtd|�����t�|d|��t�|d|d���d�S�) N�_original_pathZ _load_nameZ_redirected_namesrq���zMissing FQCN for plugin source Zansible_aliases�ansible_namer���)rK���r���r����r ���)rY���r.���r-���r9����redirected_namesrm����namesr)���r)���r/����_update_objectF��s���� zPluginLoader._update_objectc�����������������O���s���|�j�|g|�R�i�|��jS�rW���)�get_with_contextr'���)rY���r-����args�kwargsr)���r)���r/���rH���Y��s����zPluginLoader.getc�������������� ���O���s��t�|�r|���}d}|�dd�}|�dd�}||�jv�r@|�j|�}|�j||d�}|jrZ|jsdtd|�S�|j}d|vr�d� |j |f�}|j}|j} |jp�g�} | |�j vr�|��|| �|�j | <�d}|��||�j | �| ��t|�j | �|�j�}|�j�r>t|�j|�jgd�}zt||�j�} W�n�t�y&���td|��Y�S�0�t|| ��s>td|�S�|�j|�j||�j| ||d ��|�s�z<t�|�}|��||| | |��|j|g|�R�i�|���|}W�nd�t�y��}�zJd |jd�v��r�t� d|t!|�f���td|�W��Y�d}~S���W�Y�d}~n d}~0�0�|��||| | |��t||�S�) z9 instantiates a plugin of the given name using arguments T� class_onlyFr����Nr ��rs�����fromlist��found_in_cacher$��Zabstractr���zHReturning not found on "%s" as it has unimplemented abstract methods; %s)"r#���Z _strip_unsafe�popr����r����rm���rf���r&���rw���r=���rh���rg���r`���r����r��r����rO���r����r����r����r�����AttributeError� issubclass�_display_plugin_loadr����r'����__new__r ��rZ���� TypeErrorr"��r?����vr���)rY���r-���r"��r#��r(��r$��r����r(���r����r9���r��r.���r�����plugin_class�instancer��r)���r)���r/���r!��\��sV���� zPluginLoader.get_with_contextc�����������������C���s^���t�jrZd|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 %sr���z%s (searched paths: %s)z%%s (found_in_cache=%s, class_only=%s)N) r����Z DEFAULT_DEBUGr8���r9���rF���r����r����r?���r����)rY���r����r-���Zsearched_pathsr9���r(��r$��r����r)���r)���r/���r,�����s����z!PluginLoader._display_plugin_loadc�����������������o���sH��|��dd�}|��dd�}|��dd�}|r4|r4td��g�}d}t��}|����D�]D} t�ttj�| jd���} | j sx|� | ��|�t| tjj d���qJt��}|D��]�}tj�|�d �} tj� | �}|t|�j�v�r�t�d |���q�|dks�|dk�r|�jd k�rt�d|���q�|�r(||v��r(t�d|���q�|�|��|�r@|V��q�||�jv�r�|�jdv��rnd�tt|��|�}n|}z|��||�}W�nH�t�y��}�z.t�d|t|�f���W�Y�d}~q�W�Y�d}~n d}~0�0�||�j|<�d}n |�j|�}|��|||��zt||�j�}W�nH�t �yL�}�z.t�d|t|�f���W�Y�d}~q�W�Y�d}~n d}~0�0�|�j!�r�t"|�j|�j!gd�}zt||�j!�}W�n�t �y����Y�q�Y�n0�t#||��s�q�|�j$|�j||�j%|||d��|�sz||i�|��}W�n<�t&�y�}�z"t�d|t|�f���W�Y�d}~n d}~0�0�||v��r |}n d|���}|�j'||||d��|V��q�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����r���z+'%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����r���r8���r9���r=���rX����updater����r����rF���r��r����r����r?���r����r��r����r����r~����abs�hashr��rI���r@���r���r����rO���r����r*��r����r����r+��r,��r����r.��r ��)rY���r"��r#��Zdeduper3��r$��Zall_matchesr(��Zlegacy_excluding_builtinr�����matchesZloaded_modulesr9���r-���rF���r����r����r��r.���r0���fqcnr)���r)���r/���rJ������s�����" " " , zPluginLoader.all)NN)T)T)T)F)N)F)ry���FFN)ry���FFN)FFN)N)NN)NN)"rR���r[���r\����__doc__rZ���r����r����r����r����r����r����r����r����r����r����r����r����r����r>���r����r����r����r����r]���r����r����r���__contains__r��r ��rH���r!��r,��rJ���r)���r)���r)���r/���r+�������s@��� # 5 m � I k H r+���c�����������������������sl���e�Zd�ZdZd��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. Nc��������������������s,���t�t|��j||||||d��||�_i�|�_d�S�)N�r����r����)�superrA��rZ����_plugin_wrapper_type�_cached_non_collection_wrappers)rY���r����r����r����r<���Zplugin_wrapper_typer����r������ __class__r)���r/���rZ���<��s����zJinja2Loader.__init__c��������������������s���t�t|������i�|�_d�S�rW���)rC��rA��r����rE��rp���rF��r)���r/���r����A��s����zJinja2Loader._clear_cachesry���Fc�����������������C���s���t�d��d�S�)Nz,find_plugin is not supported on Jinja2Loader)�NotImplementedError)rY���r-���r����r����r����r����r)���r)���r/���r����E��s����zJinja2Loader.find_pluginc�����������������C���s���t�|�j�d�S�)N�s)r���r����rp���r)���r)���r/����method_map_nameH��s����zJinja2Loader.method_map_namec�������������� ���C���sn��g�}d��d|d|�j|g�}z6||�jvr8|��||�|�j|<�|�j|�}t||�j�}W�n:�ty��}�z"td||t|�f���W�Y�d�}~n d�}~0�0�|��} | d�u�r�td||f���zt| |�j �} | ��� ��}W�nD�t�y�}�z*t�d|�jt |�|f���|W��Y�d�}~S�d�}~0�0�|D�]Z\}} d��||f�}d��||f�}|��| �}||v��rJ�q|�j||||d��|�|���q|S�)Nrs���Zansible_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����r��rO���r����rI���r��r���rJ��r3���r?���r@���r���rD��r ��r���)rY���r����rB���r-���rK��r����r����r.���r���plugin_impl� method_map� plugin_map� func_name�funcr����Zfull�pluginr)���r)���r/����get_contained_pluginsL��s6���� , z"Jinja2Loader.get_contained_pluginsc�����������$���������s���|��dd��|��dd���t��}|�d�}|�j|i�|���|�j�|��}r�d|_||_|j|_ |j �d�rldnd|_|j |_ t||�S�d�}t|�\}}t��} || v�r�td |�d ��| �|��t�||�j�} | s�td�|���zt| j�}W�n:�t�y"�}�z td�|t|����W�Y�d�}~n d�}~0�0�|�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$�}W�n2�t%�y��}�ztt|���W�Y�d�}~n d�}~0�0�| j}| j&�r�d�|| j&�}�z@t'j(|j)|d�d �D��]$\}}}|�r�q�z:t*t+|��j,|g|�R�i�|��}t-|j.|�j/�}|���0��}W�nR�t1�y��}�z8t�2d!|�j��d"|��d#|�����W�Y�d�}~�q�W�Y�d�}~n d�}~0�0�|D�]z\}}d�3||f�} d$| j��d%|�j��d| j&��d|���}!||| fv��r�|��4|�}|�r�|j5}|�j6||!|j.j| d&����q�q��q�W�n��t�yP�}"�ztt|"�d |"d'��W�Y�d�}"~"n~d�}"~"0��ttf�yh�����Y�n^�t1�y��}#�zDt�2d(�t|#����t�"d)�t7�����tt|#�d |#d'��W�Y�d�}#~#n d�}#~#0�0�t||�S�)*Nr$��Fr����rr���Tr����r����ry���z*recursive collection redirect found for %rr���zinvalid plugin name: {0}zInvalid plugin FQCN ({0}): {1}r����r����rx���rj���rk���z{0} "{1}" is deprecated)r|���r{���r}���r����z{0} "{1}" has been removed)r|���r{���r}���r����r����r����r����rs���r����r����)r����z&redirecting (type: {0}) {1}.{2} to {3}r����)�prefixz Skipping z plugins in z$'; an error occurred while loading: r��z .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_wrappersrE��rH���rm���rg���r��rf���r��ru���rh���rn���r&����get_fqcr_and_namer����r ���r��r���Ztry_parse_fqcrr����r��r~���r���r����r����r���r?���ri���r����r���rt���r����Zvvvr���r����r����r�����pkgutil�iter_modules�__path__rC��rA��r!��rO���r'���rJ��r3���rI���r@���r=���rD��r(���r ��r���)$rY���r-���r"��r#���contextZknown_pluginrQ��r����Zleaf_key�seenr�����tsr��Z routing_entryZdeprecation_entryrx���rj���rk���Ztombstone_entryZexc_msgr����Znext_keyr����Z parent_prefixZdummyZmodule_name�ispkgrL��rM��rN��rO��rP��r����Zsrc_nameZaprer����rF��r)���r/���r!��r��s����� * �"�" $" &(zJinja2Loader.get_with_contextc�����������������o���s����|��dd���|��dd�}|��dd�}|r4|r4td��|�j|i�|���|rddd��|�j���D��E�d�H��ndd��|�j���D��E�d�H��d�S�) Nr2��r3��Fr$��r4��c�����������������s���s���|�]}|j�V��qd�S�rW���)r���r,����wr)���r)���r/���r������r1���z#Jinja2Loader.all.<locals>.<genexpr>c�����������������s���s���|�] }|V��qd�S�rW���r)���r]��r)���r)���r/���r������r1���)r)��r ���rT��rE���values)rY���r"��r#��r3��r$��r)���r)���r/���rJ������s����zJinja2Loader.allc��������������������s���|�j�r d�S�tt|��j|i�|��D��]�}|j�d�}t||�j�}z |��}W�nL�ty��}�z4t � d|�jt|j �|f���W�Y�d�}~q W�Y�d�}~n d�}~0�0�|���D��] }d|v�r�t �|��d|j ��d���q�|t|�j�v�r�t �d|���q�|��||��} |} |j�d�dk�r"d�|j�d�d�d���nd}|�|��s@|��d|���} |�j| ||j | d ��|| h}|�rr|�d|�����|D�]H} |�j��| ��}�r�t �d | ��d|j ��d|j ��d ����qv| |�j�| <��qvq�q d�S�)Nr����z9Skipping %s plugins in '%s' as it seems to be invalid: %rrs���z skipped in z.; Jinja plugin short names may not contain "."z)%s skipped due to a defined plugin filter����ry���r9��z Jinja plugin z from z" skipped; shadowed by plugin from �))rE��rC��rA��rJ���r��ru���rO���rJ��rI���r?����vvvvr����r���r���keysr����r����r����rD���countr=���rv���r ��r��rH���)rY���r"��r#��Zp_map� is_builtinZplugins_listrK��r��Zplugin_name�wrapperr>��r����Ztarget_namesZtarget_nameZexisting_pluginrF��r)���r/���rT����sB���� "0� z,Jinja2Loader._ensure_non_collection_wrappers)NN)ry���FFN)rR���r[���r\���r?��rZ���r����r����r����rJ��rR��r!��rJ���rT��� __classcell__r)���r)���rF��r/���rA��4��s��� &�rA��r����c�����������������C���s4���d|�vr|�}|d�|��}n|���d�d�}|�}||fS�)Nrs���rq���)rv���)r����r����r-���Zfqcrr)���r)���r/���rU��8��s����rU��c������������������C���s���t�t�}�d}tjd�u�rd}n tj}d}tj�|��rpt|d��n}zt|� ���}W�nL�t y��}�z4t�d� |t|����|�W��Y�d�}~W��d�����S�d�}~0�0�W�d�����n1�s�0����Y��z|d�}W�n&�ty����t�d� |���|��Y�S�0�t|�}|���}|dk�r^zt|�d |d ���|�d<�W�n(�t�yN���t�d� |���|��Y�S�0�|�d�|�d <�nt�d� |���n|�r�t�d� |���d|�d�v��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_CFGr8���r9���r�����openr����readrI���r?���r@���r~���r���r���striprH���r.��r ���r���)�filtersZuser_setZ filter_cfgr����Zfilter_datar��r|���r)���r)���r/����_load_plugin_filterC��sZ���� �F� � ���rq��c�������������� ���C���s����t��td�|�|����t|��}zRt|�dd�t�sntj � d�}d�|�t�}|dkr^t��|��n|dkrnt|��W�nH�t y������Y�n6�ty��}�zt��d�|�|���W�Y�d�}~n d�}~0�0�d�S�) NzLoading collection {0} from {1}Zrequires_ansiblery���Z'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?���rb��r���r~���r����(_does_collection_support_ansible_versionrH����ansible_versionr����r����Zget_config_valuer@���r���r ���rI���)r}���Zcollection_pathr����Zmismatch_behavior�messager����r)���r)���r/����_on_collection_load_handler}��s����rv��c�����������������C���s6���|�sdS�t�st�d��dS�t�|��}t|�j}|�|�S�)NTz_packaging Python module unavailable; unable to validate collection Ansible version requirements)r$���r?���r@���r%���Zbase_version�contains)Zrequirement_stringrt���ssZbase_ansible_versionr)���r)���r/���rs�����s���� rs��c������������������C���s<���t�jrt�d��d�S�ttjtj�}�|�����t��j t 7��_ d�S�)Nz3AnsibleCollectionFinder has already been configured)r���Zcollection_finderr���warnr���r����ZCOLLECTIONS_PATHSZCOLLECTIONS_SCAN_SYS_PATH�_installZon_collection_loadrv��)�finderr)���r)���r/����_configure_collection_loader���s���� r|��ZModuleDocFragmentzansible.plugins.doc_fragmentsZ doc_fragmentsZActionModulerj��Zaction_pluginsZ ActionBase)r����ZCacheModuler6��Z cache_pluginsZCallbackModulezansible.plugins.callbackZcallback_pluginsZ Connectionzansible.plugins.connectionZconnection_pluginsZparamikoZparamiko_sshZConnectionBaserB��ZShellModulezansible.plugins.shellZ shell_pluginsry���ri��Zlibraryzansible.module_utilsZmodule_utilsZLookupModulezansible.plugins.lookupZlookup_pluginsZ LookupBaseZFilterModulezansible.plugins.filterZfilter_pluginsZ TestModulezansible.plugins.testZtest_pluginsZStrategyModulezansible.plugins.strategyZstrategy_pluginsZStrategyBaseZTerminalModulezansible.plugins.terminalZterminal_pluginsZTerminalBaseZ VarsModulezansible.plugins.varsZvars_pluginsZCliconfzansible.plugins.cliconfZcliconf_pluginsZCliconfBaseZNetconfzansible.plugins.netconfZnetconf_pluginsZNetconfBaseZInventoryModulezansible.plugins.inventoryZinventory_pluginsZHttpApizansible.plugins.httpapiZhttpapi_pluginsZHttpApiBaseZBecomeModulezansible.plugins.becomeZbecome_plugins)NN)r����){Z __future__r���r���r���r����Z __metaclass__r����r8���Zos.pathrV��rP���r���collectionsr���r���� tracebackr���r7��r ���r8��r ���Zansibler���rt��r���r����Zansible.errorsr ���r���r���r���Zansible.module_utils._textr���r���r���Z%ansible.module_utils.compat.importlibr���Zansible.module_utils.sixr���Zansible.parsing.utils.yamlr���Zansible.parsing.yaml.loaderr���Zansible.pluginsr���r���r���r���Zansible.utils.collection_loaderr���r���Z2ansible.utils.collection_loader._collection_finderr���r���Zansible.utils.displayr ���Zansible.utils.plugin_docsr!���r"���Zansible.utils.unsafe_proxyr#���Zpackaging.specifiersr$���Zpackaging.versionr%���r�����importlib.utilr��r?���r&���r4���rC���rM���rU���r'���rV���r]���r+���rA��rU��rq��rv��rs��r|��r����ZDOC_FRAGMENT_PLUGIN_PATHr����ZDEFAULT_ACTION_PLUGIN_PATHZ action_loaderZDEFAULT_CACHE_PLUGIN_PATHZcache_loaderZDEFAULT_CALLBACK_PLUGIN_PATHZcallback_loaderZDEFAULT_CONNECTION_PLUGIN_PATHZconnection_loaderrG���ZDEFAULT_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�� !R������r�� :����� ��� ������������