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/usr/lib/python3.9/site-packages/ansible/galaxy/__pycache__/role.cpython-39.pyc
a

�)gpR�@s"ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZmZddlmZddlmZdd	lmZmZdd
lmZmZddlm Z ddl!m"Z"dd
l#m$Z$ddl%m&Z&ddl'm(Z(m)Z)e&�Z*ej+e,d�dd��Z-Gdd�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)�returncCsTd}ttd�rPt�d�}tj|_d|_zt�|d�WntjyJYn0d}|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�linknamerZLinkOutsideDestinationError)�retZti�r�7/usr/lib/python3.9/site-packages/ansible/galaxy/role.py�_check_working_data_filter2s


rc@s�eZdZeddg�Zej�dd�ej�dd�fZej�dd�Z	ej�dd�ej�dd�fZ
d	Zd'dd�Zd
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��_|dur�|�tj�tjj�j��s�tj�|�j�}n8�jD]0}tj�tj�|||��r�tj�|�j�}q�q�|�_n�jd�_dS)NZignore_certszValidate TLS certificates: %scsg|]}tj�|�j��qSr)�os�path�join�name)�.0�x��selfrr�
<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_mainrr-r�__init__Ts.

zGalaxyRole.__init__cCs |jrd|j|jfS|jSdS)zj
        Returns "rolename (version)" if version is not null
        Returns "rolename" otherwise
        z%s (%s)N)r;r*r-rrr�__repr__zszGalaxyRole.__repr__cCs|j|jkS�N)r*)r.�otherrrr�__eq__�szGalaxyRole.__eq__cCst|jt�s|jjS|jSrH)�
isinstancer:r
rDr-rrrrD�szGalaxyRole.apic
Cs�|jdur�|jD]�}|jD]�}tj�||�}tj�|�rz8t|d��}t|�|_Wd�n1sd0YWn(t	y�t
�d|j�YdS0qqq|jS)z'
        Returns role metadata
        N�rzUnable to load metadata for %sF)
r1r?rBr'r(r)�isfile�openr�	Exceptionr7�vvvvvr*)r.r(rE�	meta_path�frrr�metadata�s


,zGalaxyRole.metadatacCsT|jdur,g|_|jdur,|j�d�p(g|_t|jt�sNtd|�d|j����|jS)zC
        Returns a list of dependencies from role metadata
        NZdependencies�.Expected role dependencies to be a list. Role z% has meta/main.yml with dependencies )r2rS�getrKrr	r-rrr�metadata_dependencies�s

�z GalaxyRole.metadata_dependenciescCs�|jdur�tj�|j|j�}tj�|�r�zTzt|d�}t|�|_Wn.typt	�
d|j�YW|��dS0W|��n
|��0|jS)z+
        Returns role install info
        NrLz)Unable to load Galaxy install info for %sF)
r4r'r(r)�META_INSTALLrMrNrrOr7rPr*�close)r.�	info_pathrRrrr�install_info�s

�zGalaxyRole.install_infocCs"|jD]}tj�|�rdSqdS)NTF)r?r'r(�isdir)r.r(rrr�_exists�s
zGalaxyRole._existsc	Cs�t|jtj���d�d�}tj�tj�|jd��sHt�	tj�|jd��tj�|j|j
�}t|d��B}zt||�|_
Wn ty�YWd�dS0Wd�n1s�0YdS)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;Zinstall_dater"zw+NFT)�dictr;�datetimeZutcnow�strftimer'r(rCr)�makedirsrWrNrr4rO)r.�inforYrRrrr�_write_galaxy_install_info�s�2z%GalaxyRole._write_galaxy_install_infocCs.|jr*zt|j�WdSty(Yn0dS)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)rSrr(rOr-rrr�remove�s
zGalaxyRole.removec
Cs�|r�|jdur|j}n0d|vr@d|vr@d|d|d|jf}n|j}t�d|�zNt||jt�d�}tjdd�}|�	�}|r�|�
|�|�	�}q||��|jWSt
y�}zt�d	t|��WYd}~n
d}~00dS)
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<r7rr6r�tempfileZNamedTemporaryFile�read�writerXr*rO�errorr
)r.�	role_dataZarchive_urlZurl_fileZ	temp_file�data�errr�fetch�s&


(zGalaxyRole.fetchcCs�|jr&tjfdtjdi|j��}�n�|j�r�tj�	|j�rF|j}�q�d|jvrd|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|��Wn0t�yt
dd
�dd�|D����Yn0t|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"|�#|��|_$Wnt%�y�t
d��Yn0|j&}
|j|
d	k�r
|j|
dd	�<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��nt�+|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�qtWnft9�yn}zL|j:t:j;k�rD||d'k�rDWYd}~�qt
d/|jt7|�f��WYd}~n
d}~00�qt�d0t<|��|j�r�tj�	|j��s�zt�=|�Wn@t9t>f�y�}z"t�d1|t|�f�WYd}~n
d}~00d(Sd 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�idrcSsg|]}t|�dd���qS�r*N)rrU�r+�arrrr/-r0z&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, cSsg|]
}|j�qSr)Zvstring)r+�vrrrr/4r0���Z
github_branchZmastercSsg|]}|�dd��qSrn)rUrorrrr/<r0zX- 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.rLz7this 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*rr��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>rZscm_archive_rolerr5�specr<r'r(rMrlrDZlookup_role_by_namerZ
api_serverrUr7Zwarningr*Zfetch_role_relatedr;�len�sort�	TypeErrorr)r
r=r8rZ
is_tarfilerNZ
getmembersrB�dirnamerZextractfiler1rOr?�	enumeraterCr[rcr`rZisregZissym�getattr�replace�splitrAr�setattrr�extractrrb�OSError�errnoZEACCES�str�unlink�IOError)r.Ztmp_fileriZ
role_versionsZloose_versionsZrole_versionZ
role_tar_fileZ	meta_file�members�memberrEZmeta_parent_dirZarchive_parent_dirr?Z	paths_len�idxr(Zresolved_archive�attrZ
attr_value�relative_to�	full_path�errZrelative_path_dir�
relative_pathrkrrr�installs� 

���
 �




�

0,zGalaxyRole.installcCst|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-rrrrz�szGalaxyRole.specc	Cs�|jdur�g|_|jD]x}tj�|j|�}tj�|�rzHzt|d�}t|�|_Wn"tyrt	�
d|j�Yn0W|��n
|��0q�qt
|jt�s�td|�d|j����|jS)z+
        Returns role requirements
        NrLz"Unable to load requirements for %srTz has meta/requirements.yml )r3�META_REQUIREMENTSr'r(r)rMrNrrOr7rPr*rXrKrr	)r.Zmeta_requirementsrQrRrrr�requirements�s


zGalaxyRole.requirements)NNNN)�__name__�
__module__�__qualname__�setZSUPPORTED_SCMSr'r(r)rBrWr�Z	ROLE_DIRSrFrGrJ�propertyrDrSrVrZr\rbrcrlr�rzr�rrrrr Ls6
&





2
r )0Z
__future__rrrrZ
__metaclass__r�r^�	functoolsr'rre�collections.abcr�shutilrZansiblerZansible.errorsrr	Zansible.galaxy.apir
Zansible.galaxy.user_agentrZansible.module_utils._textrr
Z ansible.module_utils.common.yamlrrZ#ansible.module_utils.compat.versionrZansible.module_utils.urlsrZ!ansible.playbook.role.requirementrZansible.utils.displayrZansible.utils.pathrrr7�cache�boolr�objectr rrrr�<module>s0