403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/cli/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/cli/__pycache__/galaxy.cpython-311.opt-1.pyc
�

���c
i����ddlmZmZmZeZddlmZddlZddl	Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZm Z dd	l!m"Z"m#Z#dd
l$m%Z%ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1dd
l2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9m:Z:m;Z;m<Z<ddl=m>Z?ddl@mAZAddlBmCZCmDZDddlEmFZFmGZGmHZHddlImJZJddlKmLZLddlMmNZNddlOmPZPddlQmRZRddlSmTZTddlUmVZVddlWmXZXeV��ZYeJjZj[j\j]Z]gd�Z^ddid d!d"igid#d!d$igd%�ddid&�Z_d'�Z`d5d*�Zad+�Zbd6d,�Zcd-�Zdd.�ZeeGd/�d0����ZfGd1�d2e��Zgd7d3�Zheid4kreh��dSdS)8�)�absolute_import�division�print_function)�CLIN)�	dataclass)�	YAMLError)�context)�option_helpers)�AnsibleError�AnsibleOptionsError)�Galaxy� get_collections_galaxy_meta_info)�	GalaxyAPI)	�build_collection�download_collections�find_existing_collections�install_collections�publish_collection�validate_collection_name�validate_collection_path�verify_collections�SIGNATURE_COUNT_RE)�ConcreteArtifactsManager)�
GPG_ERROR_MAP)�Requirement)�
GalaxyRole)�BasicAuthToken�GalaxyToken�
KeycloakToken�NoTokenSentinel)�__version__)�is_iterable)�	yaml_dump�	yaml_load)�to_bytes�	to_native�to_text)�six)�
DataLoader)�
AnsibleLoader)�RoleRequirement)�Templar)�AnsibleCollectionConfig)�Display)�get_versioned_doclink)	)�urlT�str)�usernameFr1)�passwordFr1)�tokenFr1)�auth_urlFr1)�v3F�bool)�validate_certsFr7)�	client_idFr1)�timeoutF�int�default�False�cli�namer8�60r:)r<r>)r6r8r:r4c����fd�}|S)z�Inject an artifacts manager if not passed explicitly.

    This decorator constructs a ConcreteArtifactsManager and maintains
    the related temporary directory auto-cleanup around the target
    method invocation.
    c����d|vr�|i|��Sdtjdi}tj�dd��}|�m|�t�|��tj�dd��tj�dd��d���t
jtj	fi|��5}||d<�|i|��cddd��S#1swxYwYdS)N�artifacts_managerr8�resolved_validate_certs�keyring�required_valid_signature_count�ignore_gpg_errors)rE�required_signature_count�ignore_signature_errors)
r	�CLIARGS�get�update�	GalaxyCLI�
_resolve_pathr�under_tmpdir�C�DEFAULT_LOCAL_TMP)�args�kwargs�artifacts_manager_kwargsrE�concrete_artifact_cm�wrapped_methods     ��7/usr/lib/python3.11/site-packages/ansible/cli/galaxy.py�method_wrapperz9with_collection_artifacts_manager.<locals>.method_wrapper_s_����&�(�(�!�>�4�2�6�2�2�2�%5�g�o�F_�6`�#a� ��/�%�%�i��6�6����$�+�+�$�2�2�7�;�;�,3�O�,?�,?�@`�bf�,g�,g�+2�?�+>�+>�?R�TX�+Y�+Y�-�-�
�
�
�&�
2��#�
�
�*�
�
�	3�"�*>�F�&�'�!�>�4�2�6�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s�

C'�'C+�.C+�)rVrXs` rW�!with_collection_artifacts_managerrZXs$���3�3�3�3�3�*���
�c���t�d�|||dtt|��|g��zdtt|��|g��z||�����dS)Nz)
# {0}
{1:{cwidth}} {2:{vwidth}}
{3} {4}
�-)�cwidth�vwidth)�display�format�max�len)�path�h1�h2�w1�w2s     rW�_display_headerrkws~���O�O�C�J�J��
�
��c�3�r�7�7�B�-� � � ��c�3�r�7�7�B�-� � � ���K�������r[c��|j}d}|r|�dd��}|sd}t�d|j�d|����dS)N�versionz(unknown version)�- �, )�install_inforKrbr?)�grrprms   rW�
_display_rolerr�s_���?�L��G��4��"�"�9�d�3�3���&�%���O�O�O�"�'�'�'�7�7�3�4�4�4�4�4r[c���t�d�t|j��|jt||��t||�������dS)Nz"{fqcn:{cwidth}} {version:{vwidth}})�fqcnrmr`ra)rbrcr'rt�verrd)�
collectionr`ra�
min_cwidth�
min_vwidths     rW�_display_collectionry�sg���O�O�8�?�?�
�Z�_�
%�
%����6�:�&�&��6�:�&�&�	@�������r[c���t|��s|f}d�|D��}d�|D��}tt|t�����}tt|t�����}||fS)Nc�6�h|]}t|j����SrY)r'rt��.0�cs  rW�	<setcomp>z)_get_collection_widths.<locals>.<setcomp>�s ��5�5�5�A������5�5�5r[c�6�h|]}t|j����SrY)r'rur|s  rWrz)_get_collection_widths.<locals>.<setcomp>�s ��7�7�7�a�7�1�5�>�>�7�7�7r[��key)r"rerd)�collections�fqcn_set�version_set�fqcn_length�version_lengths     rW�_get_collection_widthsr��s~���{�#�#�&�"�o��5�5��5�5�5�H�7�7�;�7�7�7�K��c�(��,�,�,�-�-�K���[�c�2�2�2�3�3�N���&�&r[c�b�tjt|��}|�t|�d����|S)Nz% is not a valid signature count value)�re�matchr�
ValueError)�valuer�s  rW�validate_signature_countr��s5���H�'��/�/�E��}��E�H�H�H�I�I�I��Lr[c�`�eZdZUejedfed<eeed<ed���Z	dS)�RoleDistributionServerN�_api�api_serversc��|jr|jS|jD]%}	d|jvr	||_n�#t$rY�"wxYw|js|jd|_|jS)N�v1r)r�r��available_api_versions�	Exception)�self�servers  rW�apizRoleDistributionServer.api�s����9�	��9���&�	�	�F�
��F�9�9�9� &�D�I��E�:���
�
�
���
�����y�	,��(��+�D�I��y�s�,�
9�9)
�__name__�
__module__�__qualname__�t�Unionr�__annotations__�list�propertyr�rYr[rWr�r��sV�������
�'�)�T�/�
"�"�"�"��i�� � � �
����X���r[r�c���eZdZdZdZdZ�fd�Z�fd�Zd4d�Zd4d�Z	d4d	�Z
d4d
�Zd4d�Zd4d�Z
d4d
�Zd4d�Zd4d�Zd4d�Zd4d�Zd4d�Zd4d�Z�fd�Z�fd�Zed���Zd�Zd5d�Zd�Zed6d���Zed���Zed���Zed���Z 		d7d �Z!d!�Z"d"�Z#d#�Z$e%d4d$���Z&d%�Z'd&�Z(e%d4d'���Z)e%d4d(���Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/e%d4d.���Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5�xZ6S)8rMz�Command to manage Ansible roles and collections.

       None of the CLI tools are designed to run concurrently with themselves.
       Use an external scheduler and/or locking to ensure there are no clashing operations.
    zansible-galaxy)r?�description�readme_html�related�summary_fields�average_aw_composite�average_aw_scorer0c����||_d|_t|��dkr�|ddvr%d|vr!d|vr|�dd��d|_|dd�ddgkrXt�d	�ttj	������tjd��g|_d|_
d|_tt |���|��dS)
NF�)z-hz--helpz	--version�rolervT��logina$The login command was removed in late 2020. An API key is now required to publish roles or collections to Galaxy. The key can be found at https://galaxy.ansible.com/me/preferences, and passed to the ansible-galaxy CLI via a file at {0} or (insecurely) via the `--token` command-line argument.)�	_raw_args�_implicit_rolere�insertrb�errorrcr'rP�GALAXY_TOKEN_PATH�sys�exitr��galaxy�
lazy_role_api�superrM�__init__)r�rR�	__class__s  �rWr�zGalaxyCLI.__init__�s�������#����t�9�9�q�=�=��A�w�;�;�;��d�@R�@R�Wc�ko�Wo�Wo����A�v�&�&�&�&*��#��A�a�C�y�V�W�-�-�-��
�
�-�.4�V�G�A�<O�4P�4P�-Q�-Q�	S�S�S�
������������!���
�i����'�'��-�-�-�-�-r[c�@
��tt|���d���tj�d���}|�dddd�	��|�d
ddd
�	��|�dddddd���|�ddtd���tj|��tj�d���}|�dddddd���tj�d���}|�dd� ��|�d!d"� ��tj�d���}|�d#d$ddd%�&��tj
�d'���d(d)��}tj�d���}|�d*d+d,tj
d-�.��tjtjd/|z�0��tj�d���}|�d*d1d2tj
d-�.��t jtjd3�t&jj���0��tj�d���}|�d4d5ddd6���|�d7d8ddd9���|j�d:d;�<��}	d-|	_|	�d=d>� ��}
|
�d?d@�<��}d-|_|�|||g�A��|�|||g�A��|�|||g�A��|�||g�A��|�||||g�A��|�|||g�A��|� |||g�A��|	�dBdC� ��}|�dDd@�<��}
d-|
_|�|
|||g�A��|�!|
||g�A��|�"|
||g�A��|�|
||g�A��|�#|
|g�A��|�$|
||g�A��|�%|
||g�A��|�&|
|||g�A��|�|
|||g�A��dS)Ez* create an options parser for bin/ansible z7Perform various Role and Collection related operations.)�descF)�add_helpz-sz--server�
api_serverzThe Galaxy API server URL��dest�helpz--tokenz	--api-key�api_keyz[The Ansible Galaxy API key which can be found at https://galaxy.ansible.com/me/preferences.z-cz--ignore-certs�
store_true�ignore_certsz)Ignore SSL certificate validation errors.N)�actionr�r�r<z	--timeoutr:zKThe time to wait for operations against the galaxy server, defaults to 60s.)r��typer�z-fz--force�forcez0Force overwriting an existing role or collection�r�r�r<r��github_user�GitHub username�r��github_repo�GitHub repository�	--offline�offlinez.Don't query the galaxy API when creating roles)r�r<r�r��DEFAULT_ROLES_PATHr<��-p�--roles-path�
roles_pathT)�pathsepz}The path to the directory containing your roles. The default is the first writable one configured via DEFAULT_ROLES_PATH: %s )r�r�r<r�r��--collections-path�collections_pathz�One or more directories to search for collections in addition to the default COLLECTIONS_PATHS. Separate multiple paths with '{0}'.z--clear-response-cache�clear_response_cachez)Clear the existing server response cache.z
--no-cache�no_cachez%Do not use the server response cache.�TYPEr�)�metavarr�rvz$Manage an Ansible Galaxy collection.�COLLECTION_ACTIONr�)�parentsr�zManage an Ansible Galaxy role.�ROLE_ACTION)'r�rM�init_parser�opt_help�argparse�ArgumentParser�add_argumentr;�add_verbosity_optionsrP�config�get_configuration_definitionrK�unfrack_pathr��PrependListActionr-�collection_pathsrc�osrfr��parser�add_subparsers�required�
add_parser�add_download_options�add_init_options�add_build_options�add_publish_options�add_install_options�add_list_options�add_verify_options�add_remove_options�add_delete_options�add_search_options�add_import_options�add_setup_options�add_info_options)r��commonr��githubr��default_roles_pathr�r��
cache_options�type_parserrv�collection_parserr��role_parserr�s              �rWr�zGalaxyCLI.init_parser�s���	�i����*�*�J�	+�	
�	
�	
�
�"�1�1�5�1�A�A�����D�*�<�Fa��b�b�b����I�{��"N�	�	O�	O�	O�	���D�"2�<�n�dO�Y]��	^�	^�	^����K�i�c�!n�	�	p�	p�	p�	�&�v�.�.�.��!�0�0�%�0�@�@��
���4����W\� R�	�	T�	T�	T��"�1�1�5�1�A�A�����M�0A��B�B�B����M�0C��D�D�D��#�2�2�E�2�B�B�����[�y�%�P\�"R�	�	T�	T�	T��X�B�B�CW�X�X�\�\�]f�hj�k�k���&�5�5�u�5�E�E�
�����n�<�h�Nc�lp�Nq�Nq�Nq�()�(<�X�E_�&[�]o�&p�	 �	q�	q�	q�
$�,�;�;�U�;�K�K���%�%�d�,@�GY�`h�`u�C�aD�aD�aD�.E�.V�-5�-G�,4�4:�F�2�7�?�4K�4K�	&�	M�	M�	M�!�)�8�8�%�8�H�H�
��"�"�#;�BX�am�+0�7b�	#�	d�	d�	d��"�"�<�j��_d�(O�	#�	Q�	Q�	Q��k�0�0��f�0�M�M��#���!�+�+�L�?e�+�f�f�
�&�5�5�>Q�X`�5�a�a��%)��"��!�!�"3�f�m�=T�!�U�U�U����/�&�%���I�I�I����0�6�5�/��J�J�J�� � �!2�V�H� �E�E�E�� � �!2�V�U�M�<Z� �[�[�[����/�&�BR�9S��T�T�T���� 1�F�DT�;U��V�V�V��%�%�f�3S�%�T�T���)�)�-�h�)�O�O��#������k�F�E�7�3K��L�L�L�����f�j�5I��J�J�J�����f�f�5E��F�F�F����k�F�J�3G��H�H�H�����f�X��>�>�>�����f�f�5E��F�F�F����{�V�Z�4H��I�I�I����k�F�J��3P��Q�Q�Q�� � ��v�u�j�6Q� �R�R�R�R�Rr[Nc�l�|�d|d���}|�|j���|�dddd�	��|�d
ddd
dd���|�ddddd���|�dddd���|�ddd
d���dS) N�downloadzPDownload collections and their dependencies as a tarball for an offline install.�r�r���funcrRz
Collection(s)rv�*�r�r��nargs�-n�	--no-deps�no_depsr�Fz4Don't download collection(s) listed as dependencies.r�r�z--download-path�
download_pathz
./collectionsz-The directory to download the collections to.�r�r<r��-r�--requirements-file�requirementsz9A file containing a list of collections to be downloaded.r��--pre�allow_pre_release�UInclude pre-release versions. Semantic versioning pre-releases are ignored by default�r�r�r�)r��set_defaults�execute_downloadr�)r�r�r��download_parsers    rWr�zGalaxyCLI.add_download_options:s$�� �+�+�J��2D�,�E�E��	�$�$�$�*?�$�@�@�@��$�$�V�/�<�_b�$�c�c�c��$�$�T�;�Y�|�ej�*`�	%�	b�	b�	b�	�$�$�T�+<�?�-<�*Y�	%�	[�	[�	[�	�$�$�T�+@�~�*e�	%�	g�	g�	g��$�$�W�3F�|�+B�	%�	C�	C�	C�	C�	Cr[c���|jdkrdnd}|�d|d�|�����}|�|j���|�dd	d
d�|�����|�d
�|��d�|��|dkrtjntjd�|�����i}|dkr
t|d<|jd�|��fdd�|�
����i|��|dkr|�ddddd���dSdS)Nr�rvr��initz4Initialize new {0} with the base structure of a {0}.rrz--init-path�	init_path�./zaThe path in which the skeleton {0} will be created. The default is the current working directory.rz--{0}-skeleton�{0}_skeletonzAThe path to a {0} skeleton that the new {0} should be based upon.r��{0}_namer�z{0} namez--type�	role_type�storer<z_Initialize using an alternate role type. Valid types include: 'container', 'apb' and 'network'.r�)r�r�rcr�execute_initr�rP�GALAXY_COLLECTION_SKELETON�GALAXY_ROLE_SKELETONr�
capitalize)r�r�r��galaxy_typer��obj_name_kwargss      rWr�zGalaxyCLI.add_init_optionsMs���&,�n�8K�&K�&K�l�l�QW���'�'���.4�4:�F�;�4G�4G�(�I�I��	� � �d�&7� �8�8�8�� � ��[�$�'C�CI�6�+�CV�CV�	!�	X�	X�	X�	� � �!1�!8�!8��!E�!E�N�La�La�bm�Ln�Ln�IT�Xd�Id�Id��)E�)E�jk�kA�'.�.4�f�[�.A�.A�	!�	C�	C�	C�
���,�&�&�&>�O�F�#� �� ��!2�!2�;�!?�!?�	4�	4�j�FW�FW�Xc�Xn�Xn�Xp�Xp�Fq�Fq�	4�#2�	4�	4�	4��&� � ��$�$�X�K��Yb�+A�
%�
B�
B�
B�
B�
B�!� r[c��|�d|d���}|�|j���|�dddd�	��dS)
N�removezDelete roles from roles_path.rrrRzRole(s)r��+r)r�r�execute_remover�)r�r�r��
remove_parsers    rWr�zGalaxyCLI.add_remove_optionshs[���)�)�(�G�Ji�)�j�j�
��"�"��(;�"�<�<�<��"�"�6�	�6�QT�"�U�U�U�U�Ur[c�l�|�d|d���}|�|j���dS)N�deletezWRemoves the role from Galaxy. It does not remove or alter the actual GitHub repository.rr)r�r�execute_delete)r�r�r��
delete_parsers    rWr�zGalaxyCLI.add_delete_optionsnsJ���)�)�(�G�0D�*�E�E�
�	�"�"��(;�"�<�<�<�<�<r[c�J�d}|jdkrd}|�d|d�|�����}|�|j���|�||���d|�	��|dkr|�d
ddd
d���dSdS)Nr�r�rvr�zAShow the name and version of each {0} installed in the {0}s_path.rr�?)r�r	r�z--format�
output_format)�human�yaml�jsonr3z-Format to display the list of collections in.)r��choicesr<r�)r�r�rcr�execute_listr�r$)r�r�r�r%�list_parsers     rWr�zGalaxyCLI.add_list_optionsts������>�0�0�0�&�K��'�'���-p�-w�-w�yD�.E�.E�(�F�F��	� � �d�&7� �8�8�8�� � ��;�3I�3I�3K�3K�SV�`k� �l�l�l��,�&�&��$�$�Z�o�Oh�ry�*Y�
%�
[�
[�
[�
[�
[�'�&r[c�.�|�d|d���}|�|j���|�ddd���|�d	d
d���|�dd
d���|�dddd���dS)N�searchzLSearch the Galaxy database by tags, platforms, author and multiple keywords.rrz--platforms�	platformsz!list of OS platforms to filter byr�z
--galaxy-tags�galaxy_tagsz list of galaxy tags to filter byz--author�authorr�rRzSearch terms�
searchtermrr)r�r�execute_searchr�)r�r�r��
search_parsers    rWr�zGalaxyCLI.add_search_options�s����)�)�(�G�0;�*�<�<�
�	�"�"��(;�"�<�<�<��"�"�=�{�Il�"�m�m�m��"�"�?��Mo�"�p�p�p��"�"�:�H�CT�"�U�U�U��"�"�6���\_�"�`�`�`�`�`r[c�4�|�d|d���}|�|j���|�ddddd	�
��|�ddd
���|�ddd���|�ddddd�
��dS)N�importz"Import a role into a galaxy serverrr�	--no-wait�wait�store_falseTzDon't wait for import results.r�z--branch�	referencez\The name of a branch to import. Defaults to the repository's default branch (usually master)r�z--role-name�	role_namez>The name the role should have, if different than the repo namez--status�check_statusr�FzUCheck the status of the most recent import request for given github_user/github_repo.)r�r�execute_importr�)r�r�r��
import_parsers    rWr�zGalaxyCLI.add_import_options�s����)�)�(�G�Jn�)�o�o�
��"�"��(;�"�<�<�<��"�"�;�V�M�[_�(H�	#�	J�	J�	J��"�"�:�K�);�	#�	<�	<�	<�	�"�"�=�{�(h�	#�	j�	j�	j��"�"�:�N�<�af�)<�	#�	=�	=�	=�	=�	=r[c��|�d|d���}|�|j���|�dddd���|�d	d
ddd
���|�dd���|�dd���|�dd���|�dd���dS)N�setupz;Manage the integration between Galaxy and the given source.rrz--remove�	remove_idzSRemove the integration matching the provided ID value. Use --list to see ID values.rz--list�
setup_listr�FzList all of your integrations.r��source�Sourcer�r�r�r�r��secret�Secret)r�r�
execute_setupr�)r�r�r��setup_parsers    rWr�zGalaxyCLI.add_setup_options�s���(�(��'�.k�)�m�m���!�!�t�'9�!�:�:�:��!�!�*�;��(4�	"�	5�	5�	5�	�!�!�(��l�\a�'G�	"�	I�	I�	I��!�!�(��!�:�:�:��!�!�-�6G�!�H�H�H��!�!�-�6I�!�J�J�J��!�!�(��!�:�:�:�:�:r[c��|�d|d���}|�|j���|�dddd�	��dS)
N�infoz(View more details about a specific role.rrrRr)r�zrole_name[,version])r	r�r�)r�r�execute_infor�)r�r�r��info_parsers    rWr�zGalaxyCLI.add_info_options�s[���'�'���Fp�'�q�q��� � �d�&7� �8�8�8�� � ��s��I^� �_�_�_�_�_r[c���d}|�d|d���}|�|j���|�dd�|��dd	�
��|�ddd
ddd���|�ddddd���|�dddd���|�ddt
jd���|�ddd d!�"��d#}d$}|�d%d&t|t
j�'��|�d(d)td |t
j
ttj
�����*��dS)+Nrv�verifyzwCompare checksums with the collection(s) found on the server and the installed copy. This does not verify dependencies.rrrRrrzVThe installed collection(s) name. This is mutually exclusive with --requirements-file.)r�r	r��-i�--ignore-errors�
ignore_errorsr�FzRIgnore errors during verification and continue with the next specified collection.r�r�r�z\Validate collection integrity locally without contacting server for canonical manifest hash.rrrz7A file containing a list of collections to be verified.r��	--keyringrE�.The keyring used during signature verificationr�--signature�
signatures�appendaAn additional signature source to verify the authenticity of the MANIFEST.json before using it to verify the rest of the contents of a collection from a Galaxy server. Use in conjunction with a positional collection name (mutually exclusive with --requirements-file).raThe number of signatures that must successfully verify the collection. This should be a positive integer or all to signify that all signatures must be used to verify the collection. Prepend the value with + to fail if no valid signatures are found for the collection (e.g. +all).�A status code to ignore during signature verification (for example, NO_PUBKEY). Provide this option multiple times to ignore a list of status codes. Descriptions for the choices can be seen at L(https://github.com/gpg/gnupg/blob/master/doc/DETAILS#general-status-codes).� --required-valid-signature-countrF�r�r�r�r<�--ignore-signature-status-coderG�r�r�r�r�r<r6)r�r�execute_verifyr�rcrP�GALAXY_GPG_KEYRINGr��%GALAXY_REQUIRED_VALID_SIGNATURE_COUNTr1�,GALAXY_IGNORE_INVALID_SIGNATURE_STATUS_CODESr�r�keys)r�r�r�r%�
verify_parser�valid_signature_count_help�ignore_gpg_status_helps       rWr�zGalaxyCLI.add_verify_options�s��"���)�)�(�G�K{�)�|�|�
��"�"��(;�"�<�<�<��"�"�6�:�3D�3D�[�3Q�3Q�Y\�dZ�"�	[�	[�	[��"�"�4�):��Ye�ot�(|�	#�	~�	~�	~��"�"�;�Y�|�]b�)C�	#�	D�	D�	D�	�"�"�4�)>�^�(a�	#�	c�	c�	c��"�"�;�Y��H\�(X�	#�	Z�	Z�	Z��"�"�=�|�H�)G�	#�	H�	H�	H�&I�"�"]��	�"�"�#E�Ll�tL�(B�A�Ls�	#�	u�	u�	u��"�"�#C�J]�dg�px�(>��Hv�+/�
�0B�0D�0D�+E�+E�	#�	G�	G�	G�	G�	Gr[c����
�|jdkrdnd}i}|dkrd|d<d}nd|d<d}|�d	|d
�|�����}|�|j���|jdPd�|��dd�|��|�ddddd|���|���}|�dddddd�|�����|�ddddd�|�����d}d}	|dk�rg|�d d!d"|���d#�$��|�d%d&d'd(�)��|�d*d+dd,�-��|�d.d/d0ddd1���|�d2d3tj	d4�$��|�d5d6dtj
d7���|�d8d9d:d;�-��|�d<d=t|tj�>��|�d?d@td:|	tjtt!j�����A��|�dBdCdddD���dS|�d%dEd'dF�)��t%jdG���t)�fdH�|jD����}
t%jdI���
t)�
fdJ�|jD����}|jr�|
s|r�|�d2d3tj	dK�$��|�d5d6dtj
d7���|�d<d=t|tj�>��|�d?d@td:|	tjtt!j�����A��|�dLdMdNdddO���dS)QNr�rvr�zxThe collection(s) name or path/url to a tar.gz collection artifact. This is mutually exclusive with --requirements-file.r�z�Ignore errors during installation and continue with the next specified collection. This will not ignore dependency conflict errors.zRole name, URL or tar filez8Ignore errors and continue with the next specified role.�installz5Install {0}(s) from file(s), URL(s) or Ansible GalaxyrrrRrr)r�r	r[r\r]r�Fr�r
rrz+Don't download {0}s listed as dependencies.z--force-with-deps�force_with_depsz7Force overwriting an existing {0} and its dependencies.aThe number of signatures that must successfully verify the collection. This should be a positive integer or -1 to signify that all signatures must be used to verify the collection. Prepend the value with + to fail if no valid signatures are found for the collection (e.g. +all).rcr�r�r�z6The path to the directory containing your collections.rrrrz8A file containing a list of collections to be installed.r�rrrrz-Uz	--upgrade�upgradezgUpgrade installed collection artifacts. This will also update dependencies unless --no-deps is providedr^rEr_z--disable-gpg-verify�disable_gpg_verifyzSDisable GPG signature verification when installing collections from a Galaxy serverr`rarbz�An additional signature source to verify the authenticity of the MANIFEST.json before installing the collection from a Galaxy server. Use in conjunction with a positional collection name (mutually exclusive with --requirements-file).rdrFrerfrGrgr�r�z�Install collection artifacts (tarballs) without contacting any distribution servers. This does not apply to collections in remote Git repositories or URLs to remote tarballs.z--role-filez2A file containing a list of roles to be installed.z^(?<!-)-[a-zA-Z]*r[a-zA-Z]*c�>��g|]}��|���|��SrY�r�)r}�a�r_res  �rW�
<listcomp>z1GalaxyCLI.add_install_options.<locals>.<listcomp>s(���J�J�J�Q�D�J�J�q�M�M�J�q�J�J�Jr[z--role-file($|=)c�>��g|]}��|���|��SrYrv)r}rw�role_file_res  �rWryz1GalaxyCLI.add_install_options.<locals>.<listcomp>s-���&Z�&Z�&Z�Q�L�DV�DV�WX�DY�DY�&Z�q�&Z�&Z�&Zr[z9The keyring used during collection signature verificationz-gz--keep-scm-meta�
keep_scm_metazBUse tar instead of the scm archive option when packaging the role.�rR)r�r�rcr�execute_installr��add_mutually_exclusive_group�_get_default_collection_pathrPri�GALAXY_DISABLE_GPG_VERIFYr�rjr1rkr�rrlr��compiler7r�r�)r�r�r�r%�args_kwargs�ignore_errors_help�install_parser�install_exclusivernro�
contains_r�contains_role_filerxr{s            @@rWr�zGalaxyCLI.add_install_options�s�����&,�n�8K�&K�&K�l�l�QW�����,�&�&�#Q�K���"`���#?�K���![���*�*�9�g�19�9?���9L�9L�+�N�N��	�#�#��)=�#�>�>�>�#��#�m�J�4E�4E�k�4R�4R�Z]�m�m�al�m�m�m��#�#�D�*;�/�Zf�pu�);�	$�	=�	=�	=�+�G�G�I�I���&�&�t�[�y�Q]�gl�,Y�,`�,`�al�,m�,m�	'�	o�	o�	o��&�&�':�AR�[g�qv�-<�<B�F�;�<O�<O�	'�	Q�	Q�	Q�&I�"�"]���,�&�&��'�'��.B�I[�04�0Q�0Q�0S�0S�-e�
(�
g�
g�
g�
�'�'��.C�.�-g�
(�
i�
i�
i��'�'��6I�R^�.E�
(�
F�
F�
F��'�'��k�	�R^�hm�.W�
(�
X�
X�
X��'�'��)�Q�Ma�-]�
(�
_�
_�
_��'�'�(>�EY�bn�01�0K�.C�
(�
D�
D�
D�
�'�'�
�L�QY�.n�
(�
o�
o�
o�
�'�'�(J�Qq�yQ�-G�QR�Qx�
(�
z�
z�
z��'�'�(H�Ob�il�u}�-C�Q�M{�04�]�5G�5I�5I�0J�0J�
(�
L�
L�
L�
�'�'��)�L�bg�.I�
(�
*�
*�
*�
*�
*�

�'�'��m�.�-a�
(�
c�
c�
c��:�<�=�=�D��J�J�J�J�$�.�J�J�J�K�K�J��:�&9�:�:�L�!%�&Z�&Z�&Z�&Z�$�.�&Z�&Z�&Z�![�![���"�
P�
�
P�6H�
P��+�+�K�i�QR�Qe�1l�,�n�n�n��+�+�,B�I]�fr�45�4O�2G�,�H�H�H��+�+�,N�Uu�}U�1K�UV�U|�,�~�~�~��+�+�,L�Sf�mp�zB�1G�QR�Q�48��9K�9M�9M�4N�4N�,�P�P�P�
�'�'��.?�o�^j�05�-q�
(�
s�
s�
s�
s�
sr[c���|�d|d���}|�|j���|�ddddd	�
��|�ddd
d���dS)N�buildzMBuild an Ansible collection artifact that can be published to Ansible Galaxy.rrrRrvr��.z�Path to the collection(s) directory to build. This should be the directory that contains the galaxy.yml file. The default is the current working directory.)r�r	r<r�z
--output-path�output_pathrz[The path in which the collection is built to. The default is the current working directory.r)r�r�
execute_buildr�)r�r�r��build_parsers    rWr�zGalaxyCLI.add_build_options-s����(�(��'�/8�)�9�9��	�!�!�t�'9�!�:�:�:��!�!�&�,�c�SY�(4�	"�	5�	5�	5�	�!�!�/�
�t�(<�	"�	=�	=�	=�	=�	=r[c��|�d|d���}|�|j���|�ddd���|�d	d
ddd
���|�ddtdd���dS)N�publishz0Publish a collection artifact to Ansible Galaxy.rrrR�collection_pathz.The path to the collection tarball to publish.)r�r�rCrDrETz)Don't wait for import validation results.r�z--import-timeout�import_timeoutrz=The time to wait for the collection import process to finish.)r�r�r<r�)r�r�execute_publishr�r;)r�r�r��publish_parsers    rWr�zGalaxyCLI.add_publish_options;s����*�*�9�g�0b�+�d�d���#�#��)=�#�>�>�>��#�#�F�4E�)Y�	$�	[�	[�	[��#�#�K�f�]�\`�)T�	$�	V�	V�	V��#�#�$6�=M�TW�ab�)h�	$�	j�	j�	j�	j�	jr[c���tt|���|��}t|d|j�dn|j��t|d|j�|jntj��|jt_|S)Nr8rD)
r�rM�post_process_args�setattrr�r8rP�GALAXY_IGNORE_CERTS�	verbosityrb)r��optionsr�s  �rWr�zGalaxyCLI.post_process_argsGs�����	�4�(�(�:�:�7�C�C��	��)�G�4H�4P�D�D�Za�Zn�Vn�p�p�p���2�w�Oe�Oq�W�5K�5K�{|�|Q�xQ�	S�	S�	S�#�-����r[c	������tt|�����t��|_d��i}dD]%}|t
jvrt
j|||<�&g}d�tjpgD��}t|d���D�]�\}�t��fd�tD����}tt|�������}tj�d�|��tj�d���}|�d��}	|�d	��}
|d
pt&}|d}|�d��}
|d
�t
jd|d
<|d
}|
rddi|d<d|d
<|rt)||d��|d
<n.|r,|	rt+||	||
���|d
<nt-|���|d
<|�|��|�t3|j�fd|i|�������t
jd�t-t
jd���}t
jd}�rzt5�fd�|D��d��}|r|j�|��nH|j�t3|jd�f|t9|��dz|d�|����n||_t9|j��dkr:|j�t3|jdtjf|d|d�|����t=d|j��|_tjd��S)Nc���d|�d|�d�d|z|d�gdd|����d|�����ig||d	�}|tvr |�t|��|S)
NzThe z of the z Galaxy serverzgalaxy_server.%s)�sectionr�r?�ANSIBLE_GALAXY_SERVER_�_)r��ini�envr�r�)�upper�SERVER_ADDITIONALrL)r�r�r��option_type�
config_defs     rW�server_config_defz(GalaxyCLI.run.<locals>.server_config_defXs����CF�3�3����P�$6��#?�"�����V�g�m�m�o�o�o�o�s�y�y�{�{�{�[�\��%�#�
�
�J��'�'�'��!�!�"3�C�"8�9�9�9��r[)r�r�r:c��g|]}|�|��SrYrY)r}�ss  rWryz!GalaxyCLI.run.<locals>.<listcomp>ts��B�B�B�Q��B�q�B�B�Br[r�)�startc3�@�K�|]\}}}|��|||��fV��dS�NrY)r}�k�req�ensure_typer��
server_keys    ��rW�	<genexpr>z GalaxyCLI.run.<locals>.<genexpr>ysD�����}�}�[n�[\�^a�cn��#4�#4�Z��C��#U�#U�V�}�}�}�}�}�}r[�
galaxy_serverr5r9r4r2r6r8rDz/v3r�r3)�access_tokenr5r8r9)r4�priorityr�r�c3�2�K�|]}|j�k�
|V��dSr��r?)r}r��
cmd_servers  �rWr�z GalaxyCLI.run.<locals>.<genexpr>�s/�����!T�!T��q�v��?S�?S�!�?S�?S�?S�?S�!T�!Tr[�cmd_arg)r4r�r8rr<r) r�rM�runr
r�r	rJrP�GALAXY_SERVER_LIST�	enumerate�dict�
SERVER_DEFr*r#�get_single_datar��+initialize_plugin_configuration_definitions�get_plugin_options�popr rrrrLrbr�nextr�re�
GALAXY_SERVERr�r�)r��galaxy_options�optional_key�config_servers�server_list�server_priority�config_dict�defs�server_optionsr5r9�	token_valr2r6r8�	cmd_token�
config_serverr�r�r�r�s                 @@@�rWr�z
GalaxyCLI.runRs+������
�i����"�"�$�$�$��h�h���	�	�	�(��K�	M�	M�L��w��.�.�/6��|�/L��|�,����C�B�!�"6�"<�"�B�B�B��+4�[��+J�+J�+J�2	�2	�'�O�Z��}�}�}�}�}�r|�}�}�}�}�}�K� ��;�!7�!7�8�8�H�H�J�J�D�
�H�@�@��R\�^b�c�c�c��X�8�8��*�U�U�N�&�)�)�*�5�5�H�&�*�*�;�7�7�I�&�w�/�B�?�I�%�j�1�H��#�#�D�)�)�B��.�/�7�3:�?�C\�3]��/�0�+�,<�=�N��
I�
=A�%�=��7�8�'+�N�7�#��
O�*8��>�R\�C]�*^�*^��w�'�'��O��O�2?�Y�IQ�O]�JS�3U�3U�3U��w�/�/�3>�I�2N�2N�2N��w�/��!�!�.�1�1�1��!�!�)���Z�#�#�(�#�!�#�#�
�
�
�
��_�\�2�
��g�o�i�&@�A�A�A�	� ��)B�C���	.�!�!T�!T�!T�!T�^�!T�!T�!T�VZ�[�[�M��
�� �'�'�
�6�6�6�6�� �'�'�	��K��J�)�>G� ��0�0�1�4�#1�)�)�%�	)�)����� .�D���t�� � �A�%�%���#�#�I���Y���%�?H��-�%�%�!�	%�%�
�
�
�4�D�$�:J�K�K�����v�&�(�(�(r[c��|jjSr�)r�r��r�s rWr�z
GalaxyCLI.api�s���!�%�%r[c�&�tjdS)Nr)rP�COLLECTIONS_PATHSr�s rWr�z&GalaxyCLI._get_default_collection_path�s���"�1�%�%r[Tc
�b�����ggd�}t�d���}tj�|��st	dt���z���t�d�z��t|d��5}	t|��}nA#t$r4}	t	dt����dt|	�������d	}	~	wwxYw	d	d	d	��n#1swxYwY|�t	d
t���z�����fd�}
t|t��r0|st	d���|D]}|d
xx|
|��z
cc<�n�t|������td
dg����}|r2t	dtd�|����z���|�d
��pgD]}|d
xx|
|��z
cc<����fd�|�d��pgD��|d<|S)a�
        Parses an Ansible requirement.yml file and returns all the roles and/or collections defined in it. There are 2
        requirements file format:

            # v1 (roles only)
            - src: The source of the role, required if include is not set. Can be Galaxy role name, URL to a SCM repo or tarball.
              name: Downloads the role to the specified name, defaults to Galaxy name from Galaxy or name of repo if src is a URL.
              scm: If src is a URL, specify the SCM. Only git or hd are supported and defaults ot git.
              version: The version of the role to download. Can also be tag, commit, or branch name and defaults to master.
              include: Path to additional requirements.yml files.

            # v2 (roles and collections)
            ---
            roles:
            # Same as v1 format just under the roles key

            collections:
            - namespace.collection
            - name: namespace.collection
              version: version identifier, multiple identifiers are separated by ','
              source: the URL or a predefined source name that relates to C.GALAXY_SERVER_LIST
              type: git|file|url|galaxy

        :param requirements_file: The path to the requirements file.
        :param allow_old_format: Will fail if a v1 requirements file is found and this is set to False.
        :param artifacts_manager: Artifacts manager.
        :return: a dict containing roles and collections to found in the requirements file.
        )�rolesr��surrogate_or_strict��errorsz*The requirements file '%s' does not exist.z Reading requirement file at '%s'�rbz)Failed to parse the requirements yml at 'z' with the following error:
Nz"No requirements found in file '%s'c
����d|vrntj|��}t�dt	|��z��d|vrd|vrtd���t
�j�jfi|��gSt|dd���}tj�|��s0tdt|���d	t����d
����t|d��5}	�fd�d
�t|��D��D��cddd��S#t $r4}tdt����dt|�������d}~wwxYw#1swxYwYdS)N�includezfound role %s in yaml filer?�srcz!Must specify name or src for roler�r�z*Failed to find include requirements file 'z' in '�'r�c�@��g|]}t�j�jfi|����SrY)rr�r�)r}�rr�s  �rWryzNGalaxyCLI._parse_requirements_file.<locals>.parse_role_req.<locals>.<listcomp>sC��� d� d� d�UV�
�4�;��8J� P� P�a� P� P� d� d� dr[c3�>K�|]}tj|��V��dSr�)r+�role_yaml_parse)r}�is  rWr�zMGalaxyCLI._parse_requirements_file.<locals>.parse_role_req.<locals>.<genexpr>s-���� b� b���!@��!C�!C� b� b� b� b� b� br[z4Unable to load data from include requirements file: � )r+r�rb�vvvr'rrr�r�r%r�rf�isfiler&�openr$r�)�requirementr��b_include_path�	f_include�e�requirements_filer�s     ��rW�parse_role_reqz:GalaxyCLI._parse_requirements_file.<locals>.parse_role_reqs�����+�+�&�6�{�C�C�����8�7�4�=�=�H�I�I�I���%�%�%�t�*;�*;�&�'J�K�K�K�"�4�;��0B�K�K�d�K�K�L�L�!)�+�i�*@�I^�!_�!_�!_���w�~�~�n�5�5�d�&�,�*3�N�*C�*C�*C�*C�Y�O`�Ea�Ea�Ea�Ea�(c�d�d�d��.�$�/�/�[�9�[� d� d� d� d� b� b�Y�W`�Ma�Ma� b� b� b� d� d� d�[�[�[�[�[�[�[�[��%�[�[�[�*�l�.7�8I�.J�.J�.J�.J�I�VW�L�L�L�,Z�[�[�[�����[����	[�[�[�[����[�[�[�[�[�[s0�*E�,$D�
E�'/E�E�E�E"�%E"zrExpecting requirements file to be a dict with the key 'collections' that contains a list of collections to installr�r�z\Expecting only 'roles' and/or 'collections' as base keys in the requirements file. Found: %sroc�b��g|]+}tj��|��������,SrY)r�from_requirement_dict�_init_coll_req_dict)r}�collection_reqrCr��validate_signature_optionss  ���rWryz6GalaxyCLI._parse_requirements_file.<locals>.<listcomp>-sO���+�+�+�#��1��,�,�^�<�<�%�.���+�+�+r[)r%r�rf�existsrr&rbr�r�r$r�
isinstancer��setrl�
difference�joinrK)
r�r��allow_old_formatrCr�r�b_requirements_file�req_obj�file_requirements�errr��role_req�
extra_keyss
`` ``        rW�_parse_requirements_filez"GalaxyCLI._parse_requirements_file�sI������<��
�
��
'�'8�AV�W�W�W���w�~�~�1�2�2�	l��K�i�Xi�Nj�Nj�j�k�k�k����6�9J�J�K�K�K�
�%�t�
,�
,�	F��
F�$-�g�$6�$6�!�!���
F�
F�
F�"�l� �!2�3�3�3�3�Y�s�^�^�^�E�F�F�F�����
F����"�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F��$��C�i�Pa�Fb�Fb�b�c�c�c�	[�	[�	[�	[�	[�	[�*�'��.�.�	�#�
G�"�$F�G�G�G�.�
B�
B���W�%�%�%����)A�)A�A�%�%�%�%�
B�
�.�3�3�5�5�6�6�A�A�#�w�P]�F^�B_�B_�`�`�J��
[�"�$5�8A�$�)�)�J�BW�BW�8X�8X�$Z�[�[�[�.�1�1�'�:�:�@�b�
B�
B���W�%�%�%����)A�)A�A�%�%�%�%�+�+�+�+�+�+�'8�&;�&;�M�&J�&J�&P�b�
+�+�+�L��'��s6�C&�B�C&�
C�"/C�C�C&�&C*�-C*c
���t�t��sd�iSd�vs/��d��r��dd��dkr�Stt	�fd�|jD����t
|jd��d����dtj
d�	�����d<�S)
Nr?rOr�r�c3�H�K�|]}�d|j|jhv�|V��dS)rON)r?r�)r}�srvr�coll_reqs  �rWr�z0GalaxyCLI._init_coll_req_dict.<locals>.<genexpr>HsH���������H�%�$�)�T�_�)E�E�E��E�E�E�E��r[zexplicit_requirement_{name!s}r�rD)r8)r�r�rKr��iterr�rr�rcr	rJ)r�rs `rWr�zGalaxyCLI._init_coll_req_dict8s����(�D�)�)�	&��H�%�%��h�&�&��L�L��*�*�'����V�X�.�.�(�:�:��O�
"������!%�!1����
�
�
���/�6�6�!�&�)�7�����"�&��/H�I�

�
�
�

�

�����r[r�c�H�tjdstd���dS)zn
        Exits with the specified return code unless the
        option --ignore-errors was specified
        r]zR- you can use --ignore-errors to skip failed roles and finish processing the list.N)r	rJr)�rcs rW�exit_without_ignorezGalaxyCLI.exit_without_ignoreXs/�����/�	u��s�t�t�t�	u�	ur[c	�
�ddt|d��zg}|�di��}|�d|�dd����}|�d|z��t|�����D]�}|t
jvr�t||t��ry|�d|z��t||�����D]8}|t
jvr�|�d|�d	|||�����9��|�d
|�d	||������|�d��d�	|��S)Nr�zRole: %sr?�galaxy_infor�z	description: %sz	%s:z		�: �	�
)
r'rKrb�sortedrlrM�SKIP_INFO_KEYSr�r�r�)�	role_info�textrr�r�r�s      rW�_display_role_infozGalaxyCLI._display_role_infoas����[�7�9�V�+<�#=�#=�=�>�� �m�m�M�2�6�6���m�m�M�;�?�?�=�RT�3U�3U�V�V�����(�;�6�7�7�7��	���(�(�)�)�	=�	=�A��I�,�,�,���)�A�,��-�-�
=����H��N�+�+�+�!�)�A�,�"3�"3�"5�"5�6�6�J�J�C��i�6�6�6� ��K�K�K����i��l�3�6G�6G� H�I�I�I�I�J�
����1�1�1�i��l�l�;�<�<�<�<�	
���C�����z�z�$���r[c��tj�tj�tj�|������Sr�)r�rf�abspath�
expanduser�
expandvars�rfs rWrNzGalaxyCLI._resolve_path}s6���w���r�w�1�1�"�'�2D�2D�T�2J�2J�K�K�L�L�Lr[c�����tt|d���d��5}t|���d���}ddd��n#1swxYwYt	��}g}g}|D]�}|�dd��r|n|}|�|dd��}	|	s0|�dd��}
|
dkrd	}	n|
d
krg}	n|
dkri}	|	|d<|�|����tjd
���tjd�����fd�}t��}t|||d����}
||
jjd<|
�
|��}|S)Nr�r�r�r�Fr�r�r1r�r�r�r�zL\(([^)]+),\s+([^)]+)\)zC\(([^)]+)\)c���t|t��rd�d�|D����}��d|��}��d|��}t	j|dddd���S)	Nz. c�8�g|]}|�d����Sr�)�rstrip)r}�ls  rWryzKGalaxyCLI._get_skeleton_galaxy_yml.<locals>.comment_ify.<locals>.<listcomp>�s"��8�8�8��q�x�x��}�}�8�8�8r[z\1 <\2>z'\1'�uz# F)�width�initial_indent�subsequent_indent�break_on_hyphens)r�r�r��sub�textwrap�fill)�v�
const_pattern�link_patterns ��rW�comment_ifyz7GalaxyCLI._get_skeleton_galaxy_yml.<locals>.comment_ify�s|����!�T�"�"�
:��I�I�8�8�a�8�8�8�9�9��� � ��Q�/�/�A��!�!�'�1�-�-�A��=��#�d�VZ�mr�s�s�s�sr[)�required_config�optional_config��	variablesr%)r�r%r'�readrrKrbr�r�r)r,�environment�filters�template)�
template_path�inject_data�template_obj�
meta_template�galaxy_metar&r'�
meta_entry�config_listr��	meta_typer%�loader�templar�
meta_valuer#r$s               @@rW�_get_skeleton_galaxy_ymlz"GalaxyCLI._get_skeleton_galaxy_yml�s����
�(�=�1F�G�G�G��
N�
N�	W�R^�#�L�$5�$5�$7�$7�@U�V�V�V�M�	W�	W�	W�	W�	W�	W�	W�	W�	W�	W�	W����	W�	W�	W�	W�7�8�8������%�	+�	+�J�-7�^�^�J��-N�-N�c�/�/�Tc�K��O�O�J�u�$5�t�<�<�E��
�&�N�N�6�5�9�9�	���%�%��E�E��&�(�(��E�E��&�(�(��E�"'�J�w�����z�*�*�*�*��z�"<�=�=���
�?�3�3�
�	t�	t�	t�	t�	t�	t������&��ds�,t�,t�u�u�u��5@���#�M�2��%�%�m�4�4�
��s�$A�A�Ac����|r|rtd���|s|std���|rD��td���t�|��}|�|d����}n��fd�|D��gd�}|S)NzRThe positional collection_name arg and --requirements-file are mutually exclusive.z:You must specify a collection name or a requirements file.z�The --signatures option and --requirements-file are mutually exclusive. Use the --signatures with positional collection_name args or provide a 'signatures' key for requirements in the --requirements-file.F)r�rCc�<��g|]}tj|������SrY)r�from_string)r}�
coll_inputrCras  ��rWryzFGalaxyCLI._require_one_of_collections_requirements.<locals>.<listcomp>�s9��� � � �"� �+�J�8I�:�V�V� � � r[)r�r�)rrMrNr�)r�r�r�rarCrs   `` rW�(_require_one_of_collections_requirementsz2GalaxyCLI._require_one_of_collections_requirements�s�����
�	�,�	��s�t�t�t��	�%6�	��[�\�\�\�
�	��%�"�T����
!*� 7� 7�8I� J� J���8�8�!�!&�"3�9���L�L� � � � � �&1� � � ����L��r[c��dS)z�
        Perform the action on an Ansible Galaxy role. Must be combined with a further action like delete/install/init
        as listed below.
        NrYr�s rW�execute_rolezGalaxyCLI.execute_role��	��	
�r[c��dS)z�
        Perform the action on an Ansible Galaxy collection. Must be combined with a further action like init/install as
        listed below.
        NrYr�s rW�execute_collectionzGalaxyCLI.execute_collection�rAr[c�@�tjd}t�tjd��}t	|d���}t
j�|��stj|��n>t
j�	|��rtdt|��z���tjdD]K}t�|��}tt|d���t|d���|���LdS)a*
        Build an Ansible Galaxy collection artifact that can be stored in a central repository like Ansible Galaxy.
        By default, this command builds from the current working directory. You can optionally pass in the
        collection input path (where the ``galaxy.yml`` file is).
        r�r�r�r�z9- the output collection directory %s is a file - abortingrRN)r	rJrMrNr%r�rfr��makedirsr�rr&rr')r�r�r��
b_output_pathr�s     rWr�zGalaxyCLI.execute_build�s�����(���-�-�g�o�m�.L�M�M�� ��5J�K�K�K�
��w�~�~�m�,�,�	u��K�
�&�&�&�&�
�W�^�^�M�
*�
*�	u��Z�]f�gr�]s�]s�s�t�t�t�&��v�6�	�	�O�'�5�5�o�F�F�O����0E�F�F�F���,A�B�B�B��
�
�
�
�	�	r[c��tjd}tjd}tjd}tjd}|rt�|��}|�|||���d}t�|��}t|d���}tj�|��st
j	|��t|||j|tjd	|���d
S)NrRrr
r�rCr�r�r�rr)r	rJrMrNr>r%r�rfr�rErr�)r�rCr�rr
r�r�b_download_paths        rWrzGalaxyCLI.execute_download�s���o�f�-���/�)�,�����8�
�#�O�N�;���	K� )� 7� 7�8I� J� J���D�D��*�/�E�
�
����
"�/�/�
�>�>�
�"�=�9N�O�O�O���w�~�~�o�.�.�	)��K��(�(�(���-��)9�7��O�/�0�/�	
�	
�	
�	
��qr[c��%�&�'�tjd}tjd}tjd}tjd�|��}tjd�|��}td�|��t	d�����}|d	krw|�td
dd|tjd
ddddtdd�g�����tj}tj
�||��}n{|dkru|�dd��\}	}
|�t|	|
dddgdgddddg�����tj
}tj
�||	|
��}t|d���}tj
�|��r�tj
�|��rt#dt%|��z���|st#d t%|��z���tj|d!�"��D]x\}}
}|
D]6}tj
�||��}t)j|���7|D]6}tj
�||��}tj|���7�y|�d#}nd!}|jj}d$g}tj
�|��}d%�|D���'tj
�|��s0t#d&�t%|��|�����t5��}t7||�'��}tj
�|��stj|��tj|d!�"��D�]�\}}
}tj
�||���&�&�tj��}|d(}|dkr	|d)vod*|v}n|d*k}�'fd+�|
D��|
dd�<|D�]��%tj
��%��\}}tA�%�&fd,��'D����r�B|dkr�|r�&dkr�%d-kr�|�!��}|�"d.��|d/<tF�$tj
�|�&�%��|��}ttj
�|�&|��d���}tK|d0��5}|�&t|d�����ddd��n#1swxYwY��:|d1kr�|s�tj
�|�%��}tj
�|�&|��}tO|�(|��d(d���}t|�)|��d���} tK|d0��5}!|!�&| ��ddd��n#1swxYwY��tj
�tj
�|�%��|��}"t)j*tj
�|�%��tj
�||"�������|
D]e}#ttj
�|�&|#��d���}$tj
�|$��stj|$���f���tV�+d2|�,���d3|�d4���dS)5z�
        Creates the skeleton framework of a role or collection that complies with the Galaxy metadata format.
        Requires a role or collection name. The collection name must be in the format ``<namespace>.<collection>``.
        r�rr�rrzyour {0} descriptionzplugins/plugins.html)r��ansible_plugin_list_dirr�z	your namezyour company (optional)z$license (GPL-2.0-or-later, MIT, etc)rz http://example.com/issue/trackerzhttp://example.com/repositoryzhttp://docs.example.comzhttp://example.comNr�)r=�company�licenserGr�issue_tracker_url�repository_url�documentation_url�homepage_url�min_ansible_version�dependenciesrvr�r�z1.0.0z	README.mdzyour name <example@domain.com>zGPL-2.0-or-later)�	namespace�collection_namerm�readme�authorsrM�
repository�
documentation�homepage�issues�build_ignorer�r�z6- the path %s already exists, but is a file - abortingz�- the directory %s already exists. You can use --force to re-initialize this directory,
however it will reset any main.yml files that may have
been modified there already.T)�topdownFz^.*/.git_keep$c�6�g|]}tj|����SrY)r�r�)r}�xs  rWryz*GalaxyCLI.execute_init.<locals>.<listcomp>hs ��Q�Q�Q��b�j��m�m�Q�Q�Qr[z9- the skeleton path '{0}' does not exist, cannot init {1}r(r)�	playbooksr��	templatesc�L���g|]�t�fd��D�������� S)c3�B�K�|]}|����V��dSr�rv)r}r��ds  �rWr�z4GalaxyCLI.execute_init.<locals>.<listcomp>.<genexpr>�s-�����1Y�1Y��!�'�'�!�*�*�1Y�1Y�1Y�1Y�1Y�1Yr[)�any)r}rd�skeleton_ignore_res @�rWryz*GalaxyCLI.execute_init.<locals>.<listcomp>�s=����Z�Z�Z�Q�c�1Y�1Y�1Y�1Y�FX�1Y�1Y�1Y�.Y�.Y�Z�q�Z�Z�Zr[c3�~�K�|]7}|�tj�������V��8dSr�)r�r�rfr�)r}r��f�rel_roots  ��rWr�z)GalaxyCLI.execute_init.<locals>.<genexpr>�s?�����V�V�a�q�w�w�r�w�|�|�H�a�8�8�9�9�V�V�V�V�V�Vr[z
galaxy.yml.j2rUr?�wbz.j2rnr�z was created successfully)-r	rJrcr�r/rL�ansible_versionrP�GALAXY_ROLE_SKELETON_IGNOREr�rfr��split�!GALAXY_COLLECTION_SKELETON_IGNOREr%r�r�rr&�walk�shutil�rmtree�unlinkr��default_role_skeleton_pathrr)r,rE�relpath�sep�splitextre�copyr�rMr9r��writer'�_get_file_contentsr-�copyfilerb�title)(r�r%rr��obj_skeleton�obj_namer/�skeleton_ignore_expressions�obj_pathrTrU�
b_obj_path�root�dirs�files�old_dirrf�old_file�own_skeletonr6r7�rel_dirs�rel_root_dir�in_templates_dir�filename�ext�
template_datar8�b_dest_file�
galaxy_obj�src_template�	dest_file�
b_rendered�df�
f_rel_pathrd�
b_dir_pathrhrirfs(                                     @@@rWr!zGalaxyCLI.execute_inits�������o�f�-���O�K�0�	����(����~�'<�'<�[�'I�'I�J���?�:�#4�#4�[�#A�#A�B���.�5�5�k�B�B�$9�:P�$Q�$Q�
�
�
���&� � ����t�"�1�>�"�!�/�+�6�"D�>�";�1�$3�B�Q�B�$7�� � � �
�
�
�+,�*G�'��w�|�|�I�x�8�8�H�H�
�L�
(�
(�)1����Q�)?�)?�&�I�����t�#� /��"�9�:�+�,�:�7�-�9�� � � �
�
�
�+,�*M�'��w�|�|�I�y�/�J�J�H��h�/D�E�E�E�
�
�7�>�>�*�%�%�	$��w�~�~�h�'�'�
Y�"�#[�^g�hp�^q�^q�#q�r�r�r��
Y�"�$B�EN�h�DW�DW�$X�Y�Y�Y�&(�W�Z��%F�%F�%F�
$�
$�!��d�E�#�(�(�G��7�<�<��g�6�6�D��M�$�'�'�'�'� %�$�$�H��7�<�<��h�7�7�D��I�d�O�O�O�O�$��#� �L�L��L��;�A�L�+;�*<�'��w�)�)�,�7�7��Q�Q�5P�Q�Q�Q���w�~�~�l�+�+�	��Z�a�a��,�'�'�� 6� 6���
������&�K�8�8�8���w�~�~�j�)�)�	$��K�
�#�#�#�!#���t�!D�!D�!D�/	,�/	,��D�$���w���t�\�:�:�H��~�~�b�f�-�-�H�#�A�;�L��l�*�*�#/�3I�#I�#e�k�]e�Ne� � �#/�;�#>� �[�Z�Z�Z�$�Z�Z�Z�D����G��
_�
_�� "�� 0� 0�� 3� 3�
��#��V�V�V�V�V�CU�V�V�V�V�V����,�.�.�<�.�H�PS�O�O�XY�]l�Xl�Xl�%0�$4�$4�$6�$6�M�,9�,=�,=�>O�,P�,P�M�&�)�!*�!C�!C�B�G�L�L�QU�W_�ab�Dc�Dc�er�!s�!s�J�"*�2�7�<�<��(�H�+U�+U�^s�"t�"t�"t�K��k�4�0�0�]�J�"�(�(��*�EZ�)[�)[�)[�\�\�\�]�]�]�]�]�]�]�]�]�]�]����]�]�]�]���E�\�\�*:�\�#%�7�<�<��a�#8�#8�L� "����X�x�� J� J�I�$+�F�,E�,E�l�,S�,S�TU�,V�_t�$u�$u�$u�M�!)�'�*:�*:�=�*I�*I�Rg�!h�!h�!h�J��i��.�.�-�"�����,�,�,�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-��"$��������d�A�1F�1F��!U�!U�J��O�B�G�L�L��q�$9�$9�2�7�<�<��R\�;]�;]�^�^�^�^��
,�
,��%�b�g�l�l�8�X�q�&I�&I�Rg�h�h�h�
��w�~�~�j�1�1�,��K�
�+�+�+��
,�
	����k�>O�>O�>Q�>Q�>Q�>Q�S[�S[�S[�\�]�]�]�]�]s$�7%U(�(U,�/U,�X>�>Y�Yc�l�tjd}d}tjdD�]v}d|i}t|j|j|��}|j}|r'd|vr|d|d<|d=|�|��tjds}d}	|j�|d	��}nF#t$r9}|j
d
krd|jvrd|z}Yd}~n�td
|�d|�����d}~wwxYw|r|�|��n tjdr|jsd|z}nw|j
r|�|j
��t��}	|	�d|i��}
|
r|�|
��||�|��z
}��x|�|��dS)zx
        prints out detailed information about an installed role as well as info available from the galaxy API.
        r�r�rRrfrm�installed_versionr�NFi�zBad Request�- the role %s was not foundzUnable to find info about 'z': r�)r	rJrr�r�rprLr��lookup_role_by_namer�	http_code�message�_exists�metadatar+r�r�pager)r�r��datar�r
rqrp�remote_datar�r��	role_specs           rWrWzGalaxyCLI.execute_info�s
��
�_�\�2�
����O�F�+�'	7�'	7�D���,�I��D�K��);�T�B�B�B��?�L��
/���,�,�8D�Y�8O�L�!4�5�$�Y�/�� � ��.�.�.��?�9�-�
�"��Y�"&�(�">�">�t�U�"K�"K�K�K��#�Y�Y�Y��{�c�)�)�m�q�y�.H�.H�=��D��������&�,�t�t�t�UV�UV�'W�X�X�X�����
Y�����2��$�$�[�1�1�1�����+�
�B�J�
�5��<�����{�
.�� � ���-�-�-�!�#�#�C��+�+�V�T�N�;�;�I��
,�� � ��+�+�+��D�+�+�I�6�6�6�D�D��
�
�4�����s�B*�*
C-�4C(�C(�(C-c��tjd}tjd}tjd}tjd}tjd}tjd}|�t|��}|�||||���d}d	�|D��}	t	||	|j|||�
��}
t
d�|
D����rdSd
S)NrRr�r]r�rra�rarCr�c�\�g|])}tt�|������*SrY)rrMrN)r}rfs  rWryz,GalaxyCLI.execute_verify.<locals>.<listcomp>�s0��k�k�k�VZ�2�9�3J�3J�4�3P�3P�Q�Q�k�k�kr[)�local_verify_onlyrCc3�(K�|]
}|j�	|V��dSr�)�success)r}�results  rWr�z+GalaxyCLI.execute_verify.<locals>.<genexpr>�s)����B�B�&�6�>�B�v�B�B�B�B�B�Br[r�r)r	rJr�r>rr�re)r�rCr��search_pathsr]r�r�rar�resolved_paths�resultss           rWrhzGalaxyCLI.execute_verify�s����o�f�-����'9�:�����8�
�#�O�I�6��#�O�N�;���_�\�2�
��!��j�)�)�J��D�D��*�!�/�E�
�
��	��l�k�^j�k�k�k��$��.���m�/�/�	
�
�
���B�B�G�B�B�B�B�B�	��1��qr[c��tjd}tjd}d}tj�d��}|�t|��}|rt�|��}dt
|��z}g}g}tjddkr�t�tjd��}|�||||�	��}	|	d
}|	dr-t�	|�
d�����n\|s|�td
���|r�|�d��s$|�d��std���|j}
|jod|
vod|
v}|�|||���}	|	d}|	d
rM|jrd|
vsd|
vr>|jrtjntj	}||�
d����n�|���}|	d
}nftjdD]S}
t'j|
�����}|�t/|j|jfi|�����T|s|st�d��dS|r/t�d��|�|��|r4t�d��|�|||���dSdS)a�
        Install one or more roles(``ansible-galaxy role install``), or one or more collections(``ansible-galaxy collection install``).
        You can pass in a list (roles or collections) or use the file
        option listed below (these are mutually exclusive). If you pass in a list, it
        can be a name (which will be downloaded via the galaxy API and github), or it can be a local tar archive file.

        :param artifacts_manager: Artifacts manager.
        rRrNraz�The requirements file '%s' contains {0}s which will be ignored. To install these {0}s run 'ansible-galaxy {0} install -r' or to install both at the same time run 'ansible-galaxy install -r' without a custom install path.r�rvr�r�r�r�r�z3- you must specify a user/role name or a roles filez.yamlz.ymlzJInvalid role requirements file, it must end with a .yml or .yaml extensionr�r�)rCr�z'Skipping install, no requirements foundz$Starting galaxy role install processz*Starting galaxy collection install processrH)r	rJrKr�rMrNr'r>rbr�rcr�endswithrr�r�r��warningr�r+r��striprbrr�r��_execute_install_role�_execute_install_collection)r�rC�
install_itemsr�r�ra�two_type_warning�collection_requirements�role_requirementsr�galaxy_args�will_install_collections�display_func�rnamer�s               rWr~zGalaxyCLI.execute_install�s��� ���/�
�#�O�N�;�����_�(�(��6�6�
��!��j�)�)�J��	K� )� 7� 7�8I� J� J��X�Za�bs�Zt�Zt�u��
#%�����?�6�"�l�2�2�'�5�5�g�o�FX�6Y�Z�Z�O��H�H��0�%�"3�I���L�'3�=�&A�#��G�$�
=����,�3�3�F�;�;�<�<�<�� �
a�%6�%>�)�*_�`�`�`� �
b�)�2�2�7�;�;�u�?P�?Y�?Y�Z`�?a�?a�u�&�'s�t�t�t�"�n��+/�+>�,A�4�{�CZ�,A�_m�vA�`A�(�#�<�<�%�&7�/G� =� � ��
%1��$9�!� �
�.�	J��8K�	J�t�Wb�Ob�Ob�4B�k�4Q�4Q�7;�6I�#Z�7�?�?�w�{�L� �L�!1�!8�!8��!F�!F�G�G�G�G�&*�&G�&G�&I�&I�O�.:�=�.I�+�+�%�_�V�4�b�b�E�*�:�5�;�;�=�=�I�I�D�%�,�,�Z���T�EW�-`�-`�[_�-`�-`�a�a�a�a� �	�)@�	��O�O�E�F�F�F��F��	:��O�O�B�C�C�C��&�&�'8�9�9�9�"�	��O�O�H�I�I�I�
�,�,�'��"3�
-�
�
�
�
�
�		�	r[c���tjd}tjd}tjd}tjd}	tjd}n%#t$r|jrt	d����wxYwtj�dd��}	tj�d	d��}
tj}t�fd
�|D����dkrNt�
dt����d
td�|�����d���t���}t|d���}
tj�|
��stj|
��t'|||j|||||
|	||tj�dd�����dS)Nr�r]rrrrtz�Unable to properly parse command line arguments. Please use "ansible-galaxy collection install" instead of "ansible-galaxy install".rFrsc�>��g|]}|�����|��SrY)�
startswith)r}�prfs  �rWryz9GalaxyCLI._execute_install_collection.<locals>.<listcomp>ns*���B�B�B�a�q�|�|�D�/A�/A�B��B�B�Br[rz The specified collections path 'z;' is not part of the configured Ansible collections paths '�:z}'. The installed collection will not be picked up in an Ansible run, unless within a playbook-adjacent collections directory.r�r�r�)rrCrtr�)r	rJ�KeyErrorr�rrKrPr�rerbr�r'r�rr%r�rfr�rErr�)r�rrfrCr�r]rrrrtrrsr�r�rFs  `           rWr�z%GalaxyCLI._execute_install_collectionXs�������(�����8�
��/�)�,��!�/�*;�<��	�!(��1E�!F�����	�	�	��"�
�"�;����
�
	����$�O�/�/�0C�U�K�K���/�%�%�i��7�7���.���B�B�B�B�+�B�B�B�C�C�q�H�H��O�O�O�_f�gk�_l�_l�_l�_l�nu�vy�v~�v~�@P�wQ�wQ�oR�oR�oR�oR�S�
T�
T�
T�/�t�4�4�� ��5J�K�K�K�
��w�~�~�m�,�,�	'��K�
�&�&�&���+�t�'7���U�O�W�/�/�1��O�'�'�	�5�9�9�
	
�	
�	
�	
��qs�A�"Bc
���tjd}tjd}tjd}tjdp|}|D�]&}|rNtjdr<|jtjdvr#t�d|jz���St�d|jz��|j��|jd|jks|r�|rOt�d	|j�d
|jd�d|jpd����|���njt�d
|j�d|jd�d|jpd������!|s,t�dt|��z����O	|�
��}n_#t$rR}t�d
|j�dt|���d���|�
��Yd}~���d}~wwxYw|�s'|�r$|js$t�d|jz���n�|j|jz}	|	D�]�}
t�d|
z��t'��}|�|
��}t+|j|jfi|��}
d|
jvrd|
jvr|
j��u|
j�g|
|vr@t�dt|
��z��|�|
����t�d|
jz����|
jd|
jkr�|ret�d|
j�d
|
jd�d|
jpd����|
���|�|
����`t�dt|
���d|
j�d|j�d|
jd�d�	�����|r|�|
�����t�d|
jz�����|s6t�d|jz��|�
����(dS) Nrrrrr�rRzSkipping role %szProcessing role %s rmz- changing role z from z to �unspecifiedrnz (z:) is already installed - use --force to change version to z$- %s is already installed, skipping.z! was NOT installed successfully: r�z-Meta file %s is empty. Skipping dependencies.zInstalling dep %sr�z- adding dependency: %sz-- dependency %s already pending installation.z- changing dependent role z
- dependency z) from role z) differs from already installed version (z), skippingz/- dependency %s is already installed, skipping.z$- %s was NOT installed successfully.r)r	rJr?rbr�rprmr(r�r1rqrr'rr�rf�metadata_dependenciesr�debugr+r�rr�r�r��scmrb)r�r�	role_filer�
force_depsr�r��	installedr��role_dependencies�dep�dep_req�dep_info�dep_roles              rWr�zGalaxyCLI._execute_install_role�s����O�N�3�	��/�)�,���_�%6�7�
����(�6�J�� �H	+�H	+�D��
�W�_�V�4�
���'�/�Z`�Ja�9a�9a����.���:�;�;�;���K�K�-��	�9�:�:�:�� �,��$�Y�/�4�<�?�?�5�?��!�����)-����D�4E�i�4P�4P�4P�RV�R^�Ro�bo�Ro�)q�r�r�r����
�
�
�
�����)-����D�4E�i�4P�4P�4P�RV�R^�Ro�bo�Ro�)q�r�r�r� � �!����(N�QT�UY�QZ�QZ�(Z�[�[�[� �
� �L�L�N�N�	�	���
�
�
�����t�y�y�y�Za�bc�Zd�Zd�Zd�Zd� e�f�f�f��(�(�*�*�*����������
�����#
w�y�#
w��}�"w��O�O�$S�VZ�V_�$_�`�`�`�`�(,�(B�T�EV�(V�%�0�w�w���
�
�&9�C�&?�@�@�@�"1�"3�"3��#*�#:�#:�3�#?�#?��#-�d�k�4�;M�#Z�#Z�QY�#Z�#Z���h�m�3�3��8�<�8O�8O�T\�T`�Th�%�#�0�8�'�|�;�;� '���0I�G�T\�L]�L]�0]� ^� ^� ^� ,� 3� 3�H� =� =� =� =� '���0_�bj�bo�0o� p� p� p� p�'�4�Y�?�8�CS�S�S�#-�!H�$+�O�O�O�5=�]�]�]�H�DY�Zc�Dd�Dd�Dd�fn�fv�gH�{H�gH�5I�%J�%J�%J�$,�O�O�$5�$5�$5�$0�$7�$7��$A�$A�$A�$A�$+�O�O�O�5<�X�5F�5F�5F�5F��HX�HX�HX�Z^�Zc�Zc�Zc�em�ez�|E�fF�fF�fF�5G�%H�%H�%H�%H�$.�!w�$0�$7�$7��$A�$A�$A�$A�$+�O�O�4e�hp�hu�4u�$v�$v�$v�$v��
+���� F��� R�S�S�S��(�(�*�*�*���qs�F2�2
H�<AH	�	Hc
��tjdstd���tjdD]�}t|j|j|��}	|���rt�d|z��nt�d|z���n#t$r'}td|�dt|�������d}~wwxYwdS)	zV
        removes the list of roles passed as arguments from the local system.
        rRz/- you must specify at least one role to remove.z- successfully removed %sz - %s is not installed, skipping.zFailed to remove role rNr)r	rJrrr�r�r(rbr�rr&)r�rGr�r�s    rWr*zGalaxyCLI.execute_remove�s���
��v�&�	Y�%�&W�X�X�X� ���0�	_�	_�I��d�k�4�8�Y�?�?�D�
_��;�;�=�=�T��O�O�$?�)�$K�L�L�L�L��O�O�$F��$R�S�S�S����
_�
_�
_�"�l�Y�Y�Y�PY�Z[�P\�P\�P\�#]�^�^�^�����
_�����qs�AB"�"
C�,"C�Cc��tjddkr|���dStjddkr|���dSdS)z5
        List installed collections or roles
        r�r�rvN)r	rJ�execute_list_role�execute_list_collectionr�s rWr7zGalaxyCLI.execute_list�s`��
�?�6�"�f�,�,��"�"�$�$�$�$�$�
�_�V�
$��
4�
4��(�(�*�*�*�*�*�5�
4r[c
�4�d}d}g}tjd}tjd}|D�]}t�|��}tj�|��rd}n)|�d�|�����h|r�t|j
|j|tj�||�����}tj�|j��rRd}t�
dtj�|j��z��t|��n�|�d|z����5tj�|��s|�d	|z����ntj�|��s|�d
|z�����t�
d|z��t	j|��}	|	D]5}
t|j
|j|
|���}|jrt|���6��|r|rg}|D]}t�|���|s2t)d�tjd�����d
S)zQ
        List all roles installed on the local system or a specific role
        Fr�r�T�)- the configured path {0} does not exist.rz# %sr�z(- the configured path %s does not exist.z<- the configured path %s, exists, but it is not a directory.�V- None of the provided paths were usable. Please specify a valid path with --{0}s-pathr�r)r	rJrMrNr�rf�isdirrbrcrr�r�r�rb�dirnamerrr��listdirr�r�r)r��
path_found�
role_found�warnings�roles_search_pathsrGrf�	role_pathrq�
path_files�	path_file�ws            rWr�zGalaxyCLI.execute_list_role�s���
�
��
���$�_�\�:���O�F�+�	�&�	*�	*�D�!�/�/��5�5�I��w�}�}�T�"�"�
�!�
�
���� K� R� R�SW� X� X�Y�Y�Y���
*����T�-?��QS�QX�Q]�Q]�^g�ir�Qs�Qs�t�t�t���7�=�=���)�)��!%�J��O�O�F�R�W�_�_�R�W�-E�-E�$E�F�F�F�!�"�%�%�%��E���� =�	� I�J�J�J�J��w�~�~�i�0�0���O�O�$N�QZ�$Z�[�[�[���w�}�}�Y�/�/���O�O�$b�en�$n�o�o�o������� 2�3�3�3��Z�	�2�2�
�!+�*�*�I�#�D�K��1C�Y�UY�Z�Z�Z�B��{�*�%�b�)�)�)��*��	�)�	��H��	�	�A��O�O�A������	`�%�&~�'F�'F�GN�GV�W]�G^�'_�'_�`�`�
`��qr[c�`	�|�d|_tjd}ttjd��}tjd}tj}i}g}d}d}	|D�]�}
t�|
��}tj	�
|
��s.|
|vr�A|�d�|�����jtj	�
|��s)|�d�|������d}|�r�t|��|�d	��\}}
t!|��}t#tj	�|||
��d
���}tj	�
|��s*|�d�|������ftj	�
|��s*|�d�|�������d}		t'j||��}
n9#t*$r,}t-jt1|��|��Yd}~nd}~wwxYw|d
vr|
jd|
jii||<��t7|
g��\}}t9|dd||��t;|
||����St!|
��}tj	�
|��rKt<�d�|����tAtC||����}n/t<�d�|�������|s/t<�d�|������,|d
vrd�|D��||<��At7|��\}}t9|dd||��tE|tF���D]}
t;|
||������|	r|rg}|D]}t<�$|���|s2tKd�tjd�����|dkr-t<�tMj'|����n-|dkr't<�tQ|����dS)zz
        List all collections installed on the local system

        :param artifacts_manager: Artifacts manager.
        NFr2r�rvr�z=- the configured path {0}, exists, but it is not a directory.Tr�r�r�z(- unable to find {0} in collection paths>r5r4rm�
Collection�VersionzSearching {0} for collectionsz/No 'ansible_collections' directory found at {0}zNo collections found at {0}c�,�i|]}|jd|ji��S)rm)rtru)r}rvs  rW�
<dictcomp>z5GalaxyCLI.execute_list_collection.<locals>.<dictcomp>�s0��=�=�=�IS�
��)�Z�^�)D�=�=�=r[r�r�r�r5r4r))�require_build_metadatar	rJr�r-r�rMrNr�rfr�rbrcr�rrmrr%r�r�from_dir_path_as_unknownr�r(�
raise_fromrrtrur�rkryrbr�r�rrr'r�rr5�dumpsr#)r�rCr2�collections_search_pathsrU�default_collections_path�collections_in_pathsr�r��collection_foundrfr�rTrv�b_collection_path�val_err�
fqcn_width�
version_widthr�r�s                    rWr�z!GalaxyCLI.execute_list_collection+s���(�7<��4����8�
�#&�w��7I�'J�#K�#K� �!�/�,�7��#:�#K� �!�����
� ��,�U	O�U	O�D�'�5�5�d�;�;�O��7�>�>�$�'�'�
��3�3�3����� K� R� R�Sb� c� c�d�d�d���7�=�=��1�1�
���� _� f� f�gv� w� w�x�x�x���J��F
O�)��9�9�9�(7�(=�(=�c�(B�(B�%�	�:�":�?�"K�"K��$,�R�W�\�\�/�9�V`�-a�-a�j�%A�%A�%A�!��w�~�~�&7�8�8���O�O�$N�$U�$U�Ve�$f�$f�g�g�g���w�}�}�_�5�5���O�O�$c�$j�$j�kz�${�${�|�|�|��#'� �C�!,�!E�)�)�"�"�J�J��"�C�C�C��N�<��#8�#8�'�B�B�B�B�B�B�B�B�����C����!�$4�4�4�"��)�Z�^�)D�=�(��9��,B�J�<�,P�,P�)�
�M����y�*�Vc�d�d�d�#�J�
�M�J�J�J�J�#;�4�"@�"@���7�=�=��1�1�	��K�K� ?� F� F�� W� W�X�X�X�"&�'@�'�):�(�(�#�#�K�K��K�K� Q� X� X�Yh� i� i�j�j�j��"���K�K� =� D� D�_� U� U�V�V�V�� �$4�4�4�=�=�Wb�=�=�=�(��9��-C�;�,O�,O�)�
�M����y�*�Vc�d�d�d�#)��'�"B�"B�"B�O�O�J�'�
�J�
�N�N�N�N�O��	��	��H��	�	�A��O�O�A������	`�%�&~�'F�'F�GN�GV�W]�G^�'_�'_�`�`�
`��F�"�"��O�O�D�J�';�<�<�=�=�=�=�
�f�
$�
$��O�O�I�&:�;�;�<�<�<��qs�H+�+
I!�5"I�I!c���t�tjd��}tjd}tjd}t	||j||��dS)zs
        Publish a collection into Ansible Galaxy. Requires the path to the collection tarball to publish.
        rRrDr�N)rMrNr	rJrr�)r�r�rDr:s    rWr�zGalaxyCLI.execute_publish�sS��$�1�1�'�/�&�2I�J�J����v�&���/�"2�3���?�D�H�d�G�D�D�D�D�Dr[c��d}d}tjdr%d�tjd��}|sEtjds3tjds!tjdstd���|j�|tjdtjdtjd|�	��}|d
dkr(t�dtj�
��dSdg}|d
|kr!|�	d|d
|fz��n|�	d|d
z��g}|dD]6}|�	t|ddz|dz�����7t|��}d|z}|�	d��|�	|dz��|�	|dz��|dD]3}|�	||d�d|d��|dfz���4d�|��}|�|��dS)z0 searches for roles on the Ansible Galaxy serveri�NrRr)r;r<r=zYInvalid query. At least one search term, platform, galaxy tag or author must be provided.)r;�tagsr=�	page_size�countrzNo roles match your search.��colorr�r�z6Found %d roles matching your search. Showing first %s.z$Found %d roles matching your search:r�r2r�r?z %%-%ds %%s)�Name�Description)z----z-----------r�r
)
r	rJr�rr��search_rolesrbrP�COLOR_ERRORrbrerdr�)	r�r�r:�responser��max_lenr��name_len�
format_strs	         rWr?zGalaxyCLI.execute_search�sr���	����?�6�"�	7��X�X�g�o�f�5�6�6�F��	|�g�o�k�:�	|�7�?�S`�Ca�	|�jq�jy�{C�kD�	|��z�{�{�{��8�(�(��7�?�;�;W�.5�o�m�.L�U\�Ud�em�Un�{D�)�E�E���G���!�!��O�O�9���O�O�O�O��1��u���G��y�(�(��K�K�Q�U]�^e�Uf�hq�Tr�r�s�s�s�s��K�K�?�(�7�BS�S�T�T�T����Y�'�	G�	G�D��N�N�3�t�J�/�#�5��V��D�E�E�F�F�F�F��w�<�<��#�h�.�
����C�������J�!:�:�;�;�;����J�!:�:�;�;�;��Y�'�	i�	i�D��K�K�
�$�z�2B�2B�2B�D��L�L�&Q�SW�Xe�Sf�%g�g�h�h�h�h��z�z�$�����
�
�4�����qr[c��dtjtjtjtjd�}t	t
jdd���}t	t
jdd���}t
jdr|j�||���}�n�|j�	||t
jd	t
jd
���}t|��dkr�t�d
|�d|�d�d���t�dtj���|D]Q}t�|ddd�d|ddd��tj����Rt�d|�d|�d�tj���dSt�d|ddz��t
jdsmt�d|ddddz��t�d|dd�d|dd����t
jdst
jdr�g}d}|s�|j�|dd� ��}|ddd!D]U}|d|vrIt�|d"||d#���|�
|d���V|dd$d%vrd&}ntjd'��|��dS)(z+ used to import a role into Ansible Galaxy �normal)�INFO�WARNING�ERROR�SUCCESS�FAILEDr�r�r�r�rH)r�r�rFrG)rFrGr�z?WARNING: More than one Galaxy role associated with Github repo �/r��yellowr�z.The following Galaxy roles are being updated:
r�r�rTr?zI
To properly namespace this role, remove each of the above and re-import z
 from scratchrz(Successfully submitted import request %d�idrDz
Role name: %szRepo: F)�task_id�
task_messages�message_text�message_type�state)rrTr\)rP�
COLOR_WARNr��COLOR_OKr'r	rJr��get_import_task�create_import_taskrerb�
COLOR_CHANGEDrb�time�sleep)	r��colorsr�r��taskr��msg_list�finished�msgs	         rWrIzGalaxyCLI.execute_import�s�����|��]��z��m�
�
���g�o�m�<�EZ�[�[�[���g�o�m�<�EZ�[�[�[���?�>�*�	b��8�+�+��Q\�+�]�]�D�D��8�.�.�{�K�9@���9U�9@���9U�/�W�W�D��4�y�y�1�}�}�����kv�kv�kv�yD�yD�yD�!E�&.� �0�0�0���� W�_`�_n��o�o�o��V�V�A��O�O�q�1A�/B�6�/J�;�/W�/W�/W�YZ�[k�Yl�ms�Yt�u{�Y|�Y|�$}�FG�FU�O�V�V�V�V�����DO�DO�DO�Q\�Q\�Q\�!]�&'�o� �7�7�7��q��O�O�F��a��QU��V�W�W�W��?�6�*�
b�����$�q�'�:J�2K�F�2S�TZ�2[� [�\�\�\������a���1G�1G�1G��a��Q^�I_�I_� `�a�a�a��?�>�*�
	#�g�o�f�.E�
	#��H��H��	
#��x�/�/��Q���
�/�F�F����7�#3�4�_�E�3�3�C��4�y��0�0�����N�(;�6�#�n�J]�C^��_�_�_� ����D�	�2�2�2����7�7�#�'<�<�<�#�H�H��J�r�N�N�N��	
#��qr[c���tjdr�|j���}t	|��dkrt
�d��dSt
�dtj���t
�dtj���|D]M}t
�|dd�d	|d
d�d	|d�d|d
��tj����NdStjdrR|j�tjd��t
�dtj���dStjd
}tjd}tjd
}tjd}|j�	||||��}t
�d|d
�d	|d�d|d
����dS)zD Setup an integration from Github or Travis for Ansible Galaxy rolesrNrzNo integrations found.z
ID         Source     Repor�z ---------- ---------- ----------r�10r�rOr�rr�rMzDSecret removed. Integrations using this secret will not longer work.rQzAdded integration for )
r	rJr��list_secretsrerbrPr�
remove_secret�
add_secret)r��secretsrQrOr�r��resps       rWrSzGalaxyCLI.execute_setups����?�<�(�	��h�+�+�-�-�G��7�|�|�q� � ���� 8�9�9�9��q��O�O�@��
�O�S�S�S��O�O�>�a�j�O�Q�Q�Q�!�
a�
a�����v�d�|�|�|�|�V�H�EU�EU�EU�EU�W]�^k�Wl�Wl�Wl�7=�m�7L�7L�!N�UV�U_� �a�a�a�a��1��?�;�'�	��H�"�"�7�?�;�#?�@�@�@��O�O�b�jk�jt�O�u�u�u��1����*���o�m�4���o�m�4�����*���x�"�"�6�;��V�L�L������D��N�N�N�D�Q^�L_�L_�L_�ae�fs�at�at�u�v�v�v��qr[c��tjd}tjd}|j�||��}t	|d��dkr�t
�d��t
�d��t
�d��|dD]5}t
�|jd�d	|jd
�d	|j�����6t
�|d��dS)
z$ Delete a role from Ansible Galaxy. r�r��
deleted_rolesr�zDeleted the following roles:zID     User            Namez!------ --------------- ----------�8r��15�statusr)	r	rJr��delete_rolererbrrTr?)r�r�r�rr�s     rWr.zGalaxyCLI.execute_delete1s����o�m�4���o�m�4���x�#�#�K��=�=���t�O�$�%�%��)�)��O�O�:�;�;�;��O�O�9�:�:�:��O�O�?�@�@�@��_�-�
X�
X�����4�7�7�7�7�D�N�N�N�N�D�I�I� V�W�W�W�W�����X��'�'�'��qr[r�)TNT)r�)NN)7r�r�r��__doc__r?rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��staticmethodrrrNr9r>r@rCr�rZrr!rWrhr~r�r�r*r7r�r�r�r?rIrSr.�
__classcell__)r�s@rWrMrM�sG����������D�L�N�.�.�.�.�.�0QS�QS�QS�QS�QS�fC�C�C�C�&B�B�B�B�6V�V�V�V�=�=�=�=�[�[�[�[� 	a�	a�	a�	a�
=�
=�
=�
=�
;�
;�
;�
;�`�`�`�`�G�G�G�G�BWs�Ws�Ws�Ws�r=�=�=�=�
j�
j�
j�
j�	�	�	�	�	�x)�x)�x)�x)�x)�t�&�&��X�&�&�&�&�c�c�c�c�J���@�u�u�u��\�u�� � ��\� �6�M�M��\�M��+�+��\�+�^�"�����H
�
�
�
�
�
����.'����'�&��6Q^�Q^�Q^�f1�1�1�f'����'�&��>'�Y�Y�Y�'�&�Y�v)�)�)�VP�P�P�d���(+�+�+�6�6�6�p'�x�x�x�'�&�x�tE�E�E�'�'�'�R5�5�5�n���B������r[rMc�:�t�|��dSr�)rM�cli_executorr}s rW�mainr+Ds��
���4� � � � � r[�__main__)r\r])r\r]r\r]r�)j�
__future__rrrr��
__metaclass__�ansible.clirr5�os.pathr�r�rpr�r r�typingr��dataclassesr�
yaml.errorr�ansible.constants�	constantsrP�ansibler	�ansible.cli.argumentsr
r��ansible.errorsrr�ansible.galaxyr
r�ansible.galaxy.apir�ansible.galaxy.collectionrrrrrrrrr�3ansible.galaxy.collection.concrete_artifact_managerr�ansible.galaxy.collection.gpgr�0ansible.galaxy.dependency_resolution.dataclassesr�ansible.galaxy.roler�ansible.galaxy.tokenrrrr �$ansible.module_utils.ansible_releaser!rk�'ansible.module_utils.common.collectionsr"� ansible.module_utils.common.yamlr#r$�ansible.module_utils._textr%r&r'�ansible.module_utilsr(�ansible.parsing.dataloaderr)�ansible.parsing.yaml.loaderr*�!ansible.playbook.role.requirementr+�ansible.templater,�ansible.utils.collection_loaderr-�ansible.utils.displayr.�ansible.utils.plugin_docsr/rb�moves�urllib�parse�urlparser�r�rZrkrrryr�r�r�rMr+r�rYr[rW�<module>rQsj��C�B�B�B�B�B�B�B�B�B��
���������������	�	�	�	�
�
�
�
�
�
�
�
�������������!�!�!�!�!�!� � � � � � �������������<�<�<�<�<�<�<�<�<�<�<�<�<�<�C�C�C�C�C�C�C�C�(�(�(�(�(�(�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�������8�7�7�7�7�7�H�H�H�H�H�H�*�*�*�*�*�*�\�\�\�\�\�\�\�\�\�\�\�\�O�O�O�O�O�O�?�?�?�?�?�?�A�A�A�A�A�A�A�A�C�C�C�C�C�C�C�C�C�C�$�$�$�$�$�$�1�1�1�1�1�1�5�5�5�5�5�5�=�=�=�=�=�=�$�$�$�$�$�$�C�C�C�C�C�C�)�)�)�)�)�)�;�;�;�;�;�;�
�'�)�)���9��!�*��
�
�
�
��g�
���(8�9�:�;��&�)�)<�(=�>�>���
�	������>	�	�	�	�5�5�5�����
'�
'�
'���������������.}�}�}�}�}��}�}�}�@4!�!�!�!��z����D�F�F�F�F�F��r[

Youez - 2016 - github.com/yon3zu
LinuXploit