관리-도구
편집 파일: role.cpython-39.pyc
a �����)gpR����������������������@���s"��d�dl�mZmZmZ�eZd�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlZd�dlm Z �d�dlmZ�d�dlmZ�d�dlmZmZ�d�dlmZ�d�dlmZ�d�d lmZmZ�d�d lmZmZ�d�dlm Z �d�dl!m"Z"�d�d l#m$Z$�d�dl%m&Z&�d�dl'm(Z(m)Z)�e&��Z*ej+e,d�dd��Z-G�dd��de.�Z/dS�)�����)�absolute_import�division�print_functionN)�MutableSequence)�rmtree)�context)�AnsibleError�AnsibleParserError)� GalaxyAPI)� user_agent)� to_native�to_text)� yaml_dump� yaml_load)�LooseVersion)�open_url)�RoleRequirement)�Display)� is_subpath�unfrackpath)�returnc������������������C���sT���d}�t�td�rPt�d�}tj|_d|_zt�|d��W�n�tjyJ���Y�n0�d}�|�S�)zj Check if tarfile.data_filter implementation is working for the current Python version or not F�data_filterzdocs/README.mdz../README.mdz/fooT)�hasattr�tarfileZTarInfoZSYMTYPE�type�linknamer���ZLinkOutsideDestinationError)�retZti��r����7/usr/lib/python3.9/site-packages/ansible/galaxy/role.py�_check_working_data_filter2���s���� r���c�������������������@���s����e�Zd�Zeddg�Zej�dd�ej�dd�fZej�dd�Z ej�dd�ej�dd�fZ d Zd'dd�Zd d��Z dd��Zedd���Zedd���Zedd���Zedd���Zedd���Zdd��Zdd��Zdd ��Zd!d"��Zed#d$���Zed%d&���Zd S�)(� GalaxyRole�gitZhg�metazmain.ymlz main.yamlz.galaxy_install_infozrequirements.ymlzrequirements.yaml)�defaults�files�handlersr"���ZtasksZ templates�varsZtestsNc����������� ���������s����d���_�d���_d���_d���_tjd����_t�d��j���|��_ |��_ |��_|��_|pT|��_ d���_|��_��fdd�|jD����_|d�ur�|�tj�tjj��j��s�tj�|��j�}n8��jD�]0}tj�tj�|||��r�tj�|��j�}�q�q�|��_n��jd���_d�S�)NZignore_certszValidate TLS certificates: %sc��������������������s���g�|�]}t�j�|��j��qS�r���)�os�path�join�name)�.0�x��selfr���r���� <listcomp>f��������z'GalaxyRole.__init__.<locals>.<listcomp>r���)� _metadata�_metadata_dependencies� _requirements� _install_infor����CLIARGS�_validate_certs�display�debug�galaxy�_apir*����version�src�download_url�scmZroles_paths�paths�endswithr'���r(���r)����sep� META_MAIN�exists) r.���r9����apir*���r<���r;���r>���r(���� meta_mainr���r-���r����__init__T���s.���� zGalaxyRole.__init__c�����������������C���s ���|�j�rd|�j|�j�f�S�|�jS�dS�)zj Returns "rolename (version)" if version is not null Returns "rolename" otherwise z%s (%s)N)r;���r*���r-���r���r���r����__repr__z���s����zGalaxyRole.__repr__c�����������������C���s���|�j�|j�kS��N)r*���)r.����otherr���r���r����__eq__����s����zGalaxyRole.__eq__c�����������������C���s���t�|�jt�s|�jjS�|�jS�rH���)� isinstancer:���r ���rD���r-���r���r���r���rD�������s����zGalaxyRole.apic�������������� ���C���s����|�j�du�r�|�jD�]�}|�jD�]�}tj�||�}tj�|�rz8t|d��}t|�|�_�W�d����n1�sd0����Y��W�n(�t y����t �d|�j���Y���dS�0��qqq|�j�S�)z' Returns role metadata N�rzUnable to load metadata for %sF) r1���r?���rB���r'���r(���r)����isfile�openr���� Exceptionr7����vvvvvr*���)r.���r(���rE���� meta_path�fr���r���r����metadata����s���� ,zGalaxyRole.metadatac�����������������C���sT���|�j�du�r,g�|�_�|�jdur,|�j�d�p(g�|�_�t|�j�t�sNtd|���d|�j������|�j�S�)zC Returns a list of dependencies from role metadata NZdependencies�.Expected role dependencies to be a list. Role z% has meta/main.yml with dependencies )r2���rS����getrK���r���r ���r-���r���r���r����metadata_dependencies����s���� �z GalaxyRole.metadata_dependenciesc�����������������C���s����|�j�du�r�tj�|�j|�j�}tj�|�r�zTzt|d�}t|�|�_�W�n.�typ���t � d|�j���Y�W�|����dS�0�W�|����n |����0�|�j�S�)z+ Returns role install info NrL���z)Unable to load Galaxy install info for %sF) r4���r'���r(���r)����META_INSTALLrM���rN���r���rO���r7���rP���r*����close)r.���� info_pathrR���r���r���r����install_info����s���� �zGalaxyRole.install_infoc�����������������C���s"���|�j�D�]}tj�|�r�dS�qdS�)NTF)r?���r'���r(����isdir)r.���r(���r���r���r����_exists����s���� zGalaxyRole._existsc�������������� ���C���s����t�|�jtj����d�d�}tj�tj�|�jd��sHt� tj�|�jd���tj�|�j|�j �}t|d��B}zt||�|�_ W�n �ty����Y�W�d����dS�0�W�d����n1�s�0����Y��dS�)z� Writes a YAML-formatted file to the role's meta/ directory (named .galaxy_install_info) which contains some information we can use later for commands like 'list' and 'info'. z%c)r;���Zinstall_dater"���zw+NFT)�dictr;����datetimeZutcnow�strftimer'���r(���rC���r)����makedirsrW���rN���r���r4���rO���)r.����inforY���rR���r���r���r����_write_galaxy_install_info����s�����2z%GalaxyRole._write_galaxy_install_infoc�����������������C���s.���|�j�r*zt|�j��W�dS��ty(���Y�n0�dS�)z� Removes the specified role from the roles path. There is a sanity check to make sure there's a meta/main.yml file at this path so the user doesn't blow away random directories. TF)rS���r���r(���rO���r-���r���r���r����remove����s���� zGalaxyRole.removec�������������� ���C���s����|r�|�j�dur|�j�}n0d|v�r@d|v�r@d|d�|d�|�jf�}n|�j}t�d|���zNt||�jt��d�}tjdd�}|� ��}|r�|� |��|� ��}q||����|jW�S��t y��}�zt�d t|����W�Y�d}~n d}~0�0�dS�) zS Downloads the archived role to a temp location based on role data NZgithub_userZgithub_repoz*https://github.com/%s/%s/archive/%s.tar.gzz- downloading role from %s)Zvalidate_certsZ http_agentF)�deletezfailed to download the file: %s)r=���r;���r<���r7���r���r6���r����tempfileZNamedTemporaryFile�read�writerX���r*���rO����errorr ���)r.���� role_dataZarchive_urlZurl_fileZ temp_file�data�er���r���r����fetch����s&���� (zGalaxyRole.fetchc�����������������C���s���|�j�r&tjf�dtjd�i|�j��}�n�|�j�r�tj� |�j�rF|�j}�q�d|�jv�rd|�j}|�� |�}�q�|�j�|�j�}|s�t d|�j|�jjf���|�d�dkr�t�d|�j���|�j�d|d��}|�j�sPt|�d k�r.d d��|D��}z|����W�n0�t�y���t dd �dd��|D������Y�n0�t|d��|�_n |�dd���rH|d�|�_nd|�_nB|�jdk�r�|�r�t|�j�dd��|D��v�r�t d|�j|�j|f���|D�]N}|d�|�jk�r�d|v��r�|d�|�_|d�|�jk�r�d|v��r�|d�|�_�q�|�� |�}nt d��|�r�t�d|���t�|��s&t d���n�t�|d�}d�}|���}|D�]`} |�j D�]R} | | jv��rLtj�!tj�!| j��}|�s�|}| }nt|�t|�k��rL|}| }�qL�qB|�s�t d��n2zt"|�#|��|�_$W�n�t%�y����t d��Y�n0�|�j&} |�j| d �k�r |�j| d�d �<�t| �}t'| �D��]V\}}||�_t�d|�j|�jf����z�tj�(|�j��r�tj�)|�j��snt d��n8tj�dd ��s�t d!|�j���n|��*���s�t d"|�j���nt�+|�j��t,|d d#�}|D��].} | �-���s�| �.���s�q�d$D�]�}t/| |d���}�s��q�|d%k�r tj�!t/| dd&��}n&|�0|d&d'�}tjj|�1tj2���}d&}tj�|||�}t3||d(d)��s�d*|��d+|��d,|���}t |��tj�||�}tjj|�0|d&d'��1tj2���}t4| ||���q�t5���r�|j6| t7|�j�d-d.��n|�6| t7|�j����q�|��8���W���qtW�nf�t9�yn�}�zL|j:t:j;k�rD||d'�k��rDW�Y�d�}~�qt d/|�jt7|�f���W�Y�d�}~n d�}~0�0��qt�d0t<|�����|�j�r�tj� |�j��s�zt�=|��W�n@�t9t>f�y��}�z"t�d1|t|�f���W�Y�d�}~n d�}~0�0�d(S�d S�)2NZ keep_scm_metaz://z - sorry, %s was not found on %s.Z role_typeZAPPzP%s is a Container App role, and should only be installed using Ansible ContainerZversions�idr���c�����������������S���s���g�|�]}t�|�d�d���qS��r*���N)r���rU����r+����ar���r���r���r/���-��r0���z&GalaxyRole.install.<locals>.<listcomp>z�Unable to compare role versions (%s) to determine the most recent version due to incompatible version formats. Please contact the role author to resolve versioning conflicts, or specify an explicit role version to install.z, c�����������������S���s���g�|�] }|j��qS�r���)Zvstring)r+����vr���r���r���r/���4��r0������Z github_branchZmasterc�����������������S���s���g�|�]}|��d�d��qS�rn���)rU���ro���r���r���r���r/���<��r0���zX- the specified version (%s) of %s was not found in the list of available versions (%s).r*����sourcer=���zNo valid role data foundzinstalling from %sz>the downloaded file does not appear to be a valid tar archive.rL���z7this role does not appear to have a meta/main.yml file.z=this role does not appear to have a valid meta/main.yml file.z- extracting %s to %sz7the specified roles path exists and is not a directory.�forceFzJthe specified role %s appears to already exist. Use --force to replace it.zu%s doesn't appear to contain a role. please remove this directory manually if you really want to put the role here.)�follow)r*���r���r���������T)�realzInvalid z for tarfile member: path z is not a subpath of the role rj���)�filterz Could not update files in %s: %sz- %s was installed successfullyz"Unable to remove tmp file (%s): %s)?r>���r���Zscm_archive_roler���r5����specr<���r'���r(���rM���rl���rD���Zlookup_role_by_namer���Z api_serverrU���r7���Zwarningr*���Zfetch_role_relatedr;����len�sort� TypeErrorr)���r ���r=���r8���r���Z is_tarfilerN���Z getmembersrB����dirnamer���Zextractfiler1���rO���r?���� enumeraterC���r[���rc���r`���r���ZisregZissym�getattr�replace�splitrA���r����setattrr����extractr���rb����OSError�errnoZEACCES�str�unlink�IOError)r.���Ztmp_fileri���Z role_versionsZloose_versionsZrole_versionZ role_tar_fileZ meta_file�members�memberrE���Zmeta_parent_dirZarchive_parent_dirr?���Z paths_len�idxr(���Zresolved_archive�attrZ attr_value�relative_to� full_path�errZrelative_path_dir� relative_pathrk���r���r���r����install��s����� ��� � � 0,zGalaxyRole.installc�����������������C���s���t�|�j|�j|�j|�jd�S�)z� Returns role spec info { 'scm': 'git', 'src': 'http://git.example.com/repos/repo.git', 'version': 'v1.0', 'name': 'repo' } )r>���r<���r;���r*���)r]���r>���r<���r;���r*���r-���r���r���r���rz������s����zGalaxyRole.specc�������������� ���C���s����|�j�du�r�g�|�_�|�jD�]x}tj�|�j|�}tj�|�rzHzt|d�}t|�|�_�W�n"�tyr���t � d|�j���Y�n0�W�|����n |����0��q�qt |�j�t�s�td|���d|�j������|�j�S�)z+ Returns role requirements NrL���z"Unable to load requirements for %srT���z has meta/requirements.yml )r3����META_REQUIREMENTSr'���r(���r)���rM���rN���r���rO���r7���rP���r*���rX���rK���r���r ���)r.���Zmeta_requirementsrQ���rR���r���r���r����requirements���s���� zGalaxyRole.requirements)NNNN)�__name__� __module__�__qualname__�setZSUPPORTED_SCMSr'���r(���r)���rB���rW���r����Z ROLE_DIRSrF���rG���rJ����propertyrD���rS���rV���rZ���r\���rb���rc���rl���r����rz���r����r���r���r���r���r ���L���s6��� & �2 r ���)0Z __future__r���r���r���r���Z __metaclass__r����r^���� functoolsr'���r���re����collections.abcr����shutilr���Zansibler���Zansible.errorsr���r ���Zansible.galaxy.apir ���Zansible.galaxy.user_agentr���Zansible.module_utils._textr���r ���Z ansible.module_utils.common.yamlr���r���Z#ansible.module_utils.compat.versionr���Zansible.module_utils.urlsr���Z!ansible.playbook.role.requirementr���Zansible.utils.displayr���Zansible.utils.pathr���r���r7����cache�boolr����objectr ���r���r���r���r����<module>���s0���