a ì)gkã@s¢ddlmZmZmZeZddlmZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm Z m!Z!dd l"m#Z#m$Z$dd l%m&Z&m'Z'dd l(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1dd l2m3Z3dd l4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;mZ>ddl?m@ZAddlBmCZCddlDmEZEmFZFddlGmHZHmIZImJZJddlKmLZLddlMmNZNddlOmPZPddlQmRZRddlSmTZTddlUmVZVddlWmXZXddlYmZZZeXƒZ[eLj\j]j^j_Z_gd¢Z`ddid d!d"igid#d!d$igd%œddid&œZad'd(„Zbdd9d:„Zjekd;k�ržejƒdS)?é)Úabsolute_importÚdivisionÚprint_function)ÚCLIN)Ú dataclass)Ú YAMLError)Úcontext)Úoption_helpers)Ú AnsibleErrorÚAnsibleOptionsError)ÚGalaxyÚ get_collections_galaxy_meta_info)Ú GalaxyAPIÚ GalaxyError) Ú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Únamer8Z60r:)r<r>)r6r8r:r4cst ˆ¡‡fdd„ƒ}|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. cs´d|vrˆ|i|¤ŽSdtjdi}tj dd¡}|durf| t |¡tj dd¡tj dd¡dœ¡tjtj fi|¤Ž�&}||d<ˆ|i|¤ŽWdƒS1s¦0YdS)NÚartifacts_managerr8Úresolved_validate_certsÚkeyringÚrequired_valid_signature_countÚignore_gpg_errors)rBZrequired_signature_countZignore_signature_errors) rÚCLIARGSÚgetÚupdateÚ GalaxyCLIÚ _resolve_pathrZ under_tmpdirÚCZDEFAULT_LOCAL_TMP)ÚargsÚkwargsZartifacts_manager_kwargsrBZconcrete_artifact_cm©Úwrapped_method©ú6/usr/lib/python3.9/site-packages/ansible/cli/galaxy.pyÚmethod_wrapper`s$  ýÿþz9with_collection_artifacts_manager..method_wrapper)Ú functoolsÚwraps)rNrQrOrMrPÚ!with_collection_artifacts_managerYsrTé éc CsBt dj|||dtt|ƒ|gƒdtt|ƒ|gƒ||d�¡dS)Nz) # {0} {1:{cwidth}} {2:{vwidth}} {3} {4} ú-)ÚcwidthÚvwidth)ÚdisplayÚformatÚmaxÚlen)ÚpathZh1Zh2Zw1Zw2rOrOrPÚ_display_headerysùr_cCs:|j}d}|r| dd¡}|s"d}t d|j|f¡dS)NÚversionz(unknown version)z- %s, %s)Ú install_inforFrZr?)Úgrrar`rOrOrPÚ _display_role…s rcc Cs0t djt|jƒ|jt||ƒt||ƒd�¡dS)Nz"{fqcn:{cwidth}} {version:{vwidth}})Úfqcnr`rXrY)rZr[r'rdÚverr\)Ú collectionrXrYZ min_cwidthZ min_vwidthrOrOrPÚ_display_collection�s ürgcCsRt|ƒs|f}dd„|Dƒ}dd„|Dƒ}tt|td�ƒ}tt|td�ƒ}||fS)NcSsh|]}t|jƒ’qSrO)r'rd©Ú.0ÚcrOrOrPÚ œóz)_get_collection_widths..cSsh|]}t|jƒ’qSrO)r'rerhrOrOrPrk�rl©Úkey)r"r]r\)Ú collectionsZfqcn_setZ version_setZ fqcn_lengthZversion_lengthrOrOrPÚ_get_collection_widths˜srpcCs&t t|¡}|dur"t|›d�ƒ‚|S)Nz% is not a valid signature count value)ÚreÚmatchrÚ ValueError)ÚvaluerrrOrOrPÚvalidate_signature_count¥s ruc@s8eZdZUejedfed<eeed<edd„ƒZ dS)ÚRoleDistributionServerNÚ_apiÚ api_serversc Csb|jr |jS|jD]6}zd|jvr.||_WqJWqtyFYqYq0q|js\|jd|_|jS)NZv1r)rwrxÚavailable_api_versionsÚ Exception)ÚselfZserverrOrOrPÚapi³s      zRoleDistributionServer.api) Ú__name__Ú __module__Ú __qualname__ÚtÚUnionrÚ__annotations__ÚlistÚpropertyr|rOrOrOrPrv®s  rvcsàeZdZdZdZdZ‡fdd„Z‡fdd„Zdad d „Zdbd d „Z dcd d„Z dddd„Z dedd„Z dfdd„Z dgdd„Zdhdd„Zdidd„Zdjdd„Zdkdd„Zdldd „Zdmd!d"„Z‡fd#d$„Z‡fd%d&„Zed'd(„ƒZd)d*„Zdnd,d-„Zd.d/„Zedod1d2„ƒZed3d4„ƒZed5d6„ƒZed7d8„ƒZ dpd9d:„Z!d;d<„Z"d=d>„Z#d?d@„Z$e%dqdAdB„ƒZ&dCdD„Z'dEdF„Z(e%drdGdH„ƒZ)e%dsdIdJ„ƒZ*dKdL„Z+dMdN„Z,dOdP„Z-dQdR„Z.dSdT„Z/e%dtdUdV„ƒZ0dWdX„Z1dYdZ„Z2d[d\„Z3d]d^„Z4d_d`„Z5‡Z6S)urHzá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?Ú descriptionZ readme_htmlZrelatedÚsummary_fieldsZaverage_aw_compositeZaverage_aw_scorer0cs ||_d|_t|ƒdkrz|ddvrFd|vrFd|vrF| dd¡d|_|dd…ddgkrzt d  ttj ƒ¡¡t   d¡g|_ d|_ d|_tt|ƒ |¡dS) NFé)z-hz--helpz --versionÚrolerfTéZlogina$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_roler]ÚinsertrZÚerrorr[r'rJZGALAXY_TOKEN_PATHÚsysÚexitrxÚgalaxyÚ lazy_role_apiÚsuperrHÚ__init__)r{rK©Ú __class__rOrPr“Ñs"  ýÿ zGalaxyCLI.__init__c sBtt|ƒjdd�tjjdd�}|jddddd �|jd d d d d �|jddddddd�|jddtddd�t |¡tjjdd�}|jddddddd�tjjdd�}|jdd d!�|jd"d#d!�tjjdd�}|jd$d%ddd&d'�t j   d(¡  d)d*¡}tjjdd�}|jd+d,d-tj d.d/�t jtjd0|d1�tjjdd�}|jd+d2d3tj d.d/�tjtjd4 tjj¡d1�tjjdd�}|jd5d6ddd7d�|jd8d9ddd:d�|jjd;dd?d!�} | j|jd@�| jdAdBd=�} d.| _|j| ||gdC�|j| ||gdC�|j| ||gdC�|j| |gdC�|j | |||gdC�|j!| ||gdC�|j"| ||gdC�| jdDdEd!�} | j|j#d@�| jdFdBd=�} d.| _|j| |||gdC�|j$| ||gdC�|j%| ||gdC�|j!| ||gdC�|j&| |gdC�|j'| ||gdC�|j(| ||gdC�|j)| |||gdC�|j | |||gdC�dS)Gz* create an options parser for bin/ansible z7Perform various Role and Collection related operations.)ZdescF)Ú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<rš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.ZTYPEr¡)Úmetavarr™rfz$Manage an Ansible Galaxy collection.©ÚfuncÚCOLLECTION_ACTIONrž)ÚparentsrˆzManage an Ansible Galaxy role.Z ROLE_ACTION)*r’rHÚ init_parserÚopt_helpÚargparseÚArgumentParserÚ add_argumentr;Zadd_verbosity_optionsrJÚconfigZget_configuration_definitionrFZ unfrack_pathr«ZPrependListActionr-Úcollection_pathsr[Úosr^r°ÚparserÚadd_subparsersÚrequiredÚ add_parserÚ set_defaultsÚexecute_collectionÚadd_download_optionsÚadd_init_optionsÚadd_build_optionsÚadd_publish_optionsÚadd_install_optionsÚadd_list_optionsÚadd_verify_optionsÚ execute_roleÚadd_remove_optionsÚadd_delete_optionsÚadd_search_optionsÚadd_import_optionsÚadd_setup_optionsÚadd_info_options)r{Úcommonr¢ZgithubrªZdefault_roles_pathr¯r²Z cache_optionsZ type_parserrfZcollection_parserrˆZ role_parserr”rOrPrºés’ ÿ ÿ ÿ ÿ ÿÿþþý ÿ ÿzGalaxyCLI.init_parserNcCs‚|jd|dd�}|j|jd�|jddddd �|jd d d d ddd�|jdddddd�|jddddd�|jddd dd�dS) NZdownloadúPDownload collections and their dependencies as a tarball for an offline install.©r¹ršr¶rKz Collection(s)rfÚ*©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ÅrÆÚexecute_downloadr¾)r{rÂr¹Zdownload_parserrOrOrPrÈ>s$ÿÿ þ ÿ ÿzGalaxyCLI.add_download_optionscCsÜ|jdkrdnd}|jd|d |¡d�}|j|jd�|jdd d d  |¡d �|jd  |¡d |¡|dkrptjntjd |¡d �i}|dkr–t |d<|jd |¡fdd |  ¡¡i|¤Ž|dkrØ|jdddddd�dS)Nr¸rfrˆÚinitz4Initialize new {0} with the base structure of a {0}.rØr¶z --init-pathÚ init_pathú./zaThe path in which the skeleton {0} will be created. The default is the current working directory.ràz--{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År[rÆÚ execute_initr¾rJZGALAXY_COLLECTION_SKELETONZGALAXY_ROLE_SKELETONrÚ capitalize)r{rÂr¹Ú galaxy_typerºZobj_name_kwargsrOrOrPrÉQs8ÿÿ ÿÿÿþÿ ÿzGalaxyCLI.add_init_optionscCs4|jd|dd�}|j|jd�|jddddd �dS) NÚremovezDelete roles from roles_path.rØr¶rKzRole(s)rˆú+rÚ)rÅrÆÚexecute_remover¾)r{rÂr¹Z remove_parserrOrOrPrÐlszGalaxyCLI.add_remove_optionscCs"|jd|dd�}|j|jd�dS)NÚdeletezWRemoves the role from Galaxy. It does not remove or alter the actual GitHub repository.rØr¶)rÅrÆÚexecute_delete)r{rÂr¹Z delete_parserrOrOrPrÑrsÿzGalaxyCLI.add_delete_optionscCsld}|jdkrd}|jd|d |¡d�}|j|jd�|j|| ¡d|d �|dkrh|jd d d d dd�dS)Nrˆr¸rfrƒzAShow the name and version of each {0} installed in the {0}s_path.rØr¶ú?)ršrÛrµz--formatÚ output_format)ÚhumanÚyamlÚjsonrúz-Format to display the list of collections in.)r™Úchoicesr<rš)rµrÅr[rÆÚ execute_listr¾rñ)r{rÂr¹ròZ list_parserrOrOrPrÍxs ÿ ÿzGalaxyCLI.add_list_optionscCsd|jd|dd�}|j|jd�|jdddd�|jd d d d�|jd d dd�|jddddd�dS)NÚsearchzLSearch the Galaxy database by tags, platforms, author and multiple keywords.rØr¶z --platformsÚ platformsz!list of OS platforms to filter byr˜z --galaxy-tagsÚ galaxy_tagsz list of galaxy tags to filter byz--authorÚauthorr¥rKz Search termsZ searchtermrÙrÚ)rÅrÆÚexecute_searchr¾)r{rÂr¹Z search_parserrOrOrPrÒˆsÿzGalaxyCLI.add_search_optionscCsj|jd|dd�}|j|jd�|jddddd d �|jd d d d�|jdddd�|jdddddd �dS)NÚimportz"Import a role into a galaxy serverrØr¶ú --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¹Z import_parserrOrOrPrÓ“s ÿÿÿ ÿzGalaxyCLI.add_import_optionscCs€|jd|dd�}|j|jd�|jddddd�|jd d d d d d�|jddd�|jddd�|jddd�|jddd�dS)NZsetupz;Manage the integration between Galaxy and the given source.rØr¶z--removeÚ remove_idzSRemove the integration matching the provided ID value. Use --list to see ID values.ràz--listÚ setup_listrœFzList all of your integrations.r£ÚsourceZSourcer¦r¤r¥r§r¨ÚsecretZSecret)rÅrÆÚ execute_setupr¾)r{rÂr¹Z setup_parserrOrOrPrÔ¢sÿ ÿ ÿzGalaxyCLI.add_setup_optionscCs4|jd|dd�}|j|jd�|jddddd �dS) NÚinfoz(View more details about a specific role.rØr¶rKrôrˆzrole_name[,version])rÛršrµ)rÅrÆÚ execute_infor¾)r{rÂr¹Z info_parserrOrOrPrÕ±szGalaxyCLI.add_info_optionsc Csàd}|jd|dd�}|j|jd�|jdd |¡dd d �|jd d d dddd�|jdddddd�|jddddd�|jddtjdd�|jddd d!d"�d#}d$}|jd%d&t|tjd'�|jd(d)t d |tj t t   ¡ƒd*�dS)+NrfZverifyúwCompare checksums with the collection(s) found on the server and the installed copy. This does not verify dependencies.rØr¶rKrírÙzVThe 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.rárârãz7A file containing a list of collections to be verified.r˜ú --keyringrBú.The keyring used during signature verificationràú --signatureÚ signaturesÚappenda An 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).rçaThe 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-countrC©r™r¡ršr<ú--ignore-signature-status-coderD©r™r¡ržršr<rý)rÅrÆÚexecute_verifyr¾r[rJÚGALAXY_GPG_KEYRINGruÚ%GALAXY_REQUIRED_VALID_SIGNATURE_COUNTr1Ú,GALAXY_IGNORE_INVALID_SIGNATURE_STATUS_CODESrƒrÚkeys)r{rÂr¹ròZ verify_parserÚvalid_signature_count_helpÚignore_gpg_status_helprOrOrPrηs8ÿ ÿ ÿ ÿ ÿ ÿ  þzGalaxyCLI.add_verify_optionsc s |jdkrdnd}i}|dkr,d|d<d}n d|d<d}|jd |d  |¡d �}|j|jd �|jdQd |¡ddœ|¤Ž|jddddd|d�| ¡}|jdddddd |¡d�|jddddd |¡d�d}d} |dk�rº|jd d!d"| ¡d#d$�|jd%d&d'd(d)�|jd*d+dd,d-�|jd.d/d0ddd1d�|jd2d3tj d4d$�|jd5d6dtj d7d�|jd8d9d:d;d-�|jd�|jd?d@t d:| tjtt ¡ƒdA�|jdBdCdddDd�nâ|jd%dEd'dFd)�t dG¡‰t‡fdHdI„|jDƒƒ} t dJ¡‰t‡fdKdI„|jDƒƒ} |j�r†| �s$| �r†|jd2d3tj dLd$�|jd5d6dtj d7d�|jd�|jd?d@t d:| tjtt ¡ƒdA�|jdMdNdOdddPd�dS)RNr¸rfrˆ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 GalaxyrØr¶rKrírÙ)rµrÛrrrrœFr£rÜrÝrÞ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).rr­r±r²z6The path to the directory containing your collections.ràrárârãz8A file containing a list of collections to be installed.r˜rärårærçz-Uz --upgradeÚupgradezgUpgrade installed collection artifacts. This will also update dependencies unless --no-deps is providedrrBrz--disable-gpg-verifyÚdisable_gpg_verifyzSDisable GPG signature verification when installing collections from a Galaxy serverrrrzé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).rrCrrrDr r©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^(?rlz1GalaxyCLI.add_install_options..z--role-file($|=)csg|]}ˆ |¡r|‘qSrOr,r-)Ú role_file_rerOrPr0rlz9The keyring used during collection signature verificationz-gz--keep-scm-metaZ keep_scm_metazBUse tar instead of the scm archive option when packaging the role.)rK)rµrÅr[rÆÚexecute_installr¾Úadd_mutually_exclusive_groupÚ_get_default_collection_pathrJr"ZGALAXY_DISABLE_GPG_VERIFYrur#r1r$rƒrr%rqÚcompiler7rŠr‹) r{rÂr¹ròZ args_kwargsZignore_errors_helpZinstall_parserZinstall_exclusiver&r'Z contains_rZcontains_role_filerO)r/r1rPrÌØs°ÿÿÿÿ ÿÿ  þ ÿ ÿÿ ÿ þ ÿ ÿ  þ ÿ ÿ   ÿ þ ÿ  þ þzGalaxyCLI.add_install_optionscCsH|jd|dd�}|j|jd�|jddddd d �|jd d d dd�dS)NZbuildzMBuild an Ansible collection artifact that can be published to Ansible Galaxy.rØr¶rKrfrÙ©Ú.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_pathrëz[The path in which the collection is built to. The default is the current working directory.rà)rÅrÆÚ execute_buildr¾)r{rÂr¹Z build_parserrOrOrPrÊ1sÿ ÿ ÿzGalaxyCLI.add_build_optionscCsZ|jd|dd�}|j|jd�|jdddd�|jd d d d d d�|jddtddd�dS)NZpublishz0Publish a collection artifact to Ansible Galaxy.rØr¶rKÚcollection_pathz.The path to the collection tarball to publish.)rµršrrrTz)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ÆÚexecute_publishr¾r;)r{rÂr¹Zpublish_parserrOrOrPrË?sÿÿ ÿ ÿzGalaxyCLI.add_publish_optionscsZtt|ƒ |¡}t|d|jdur$dn|j ƒt|d|jdurD|jntj ƒ|jt _|S)Nr8rA) r’rHÚpost_process_argsÚsetattrr�r8rJZGALAXY_IGNORE_CERTSÚ verbosityrZ)r{Úoptionsr”rOrPr=Ks  zGalaxyCLI.post_process_argscsztt|ƒ ¡tƒ|_dd„‰i}dD]}|tjvr&tj|||<q&g}dd„tjpVgDƒ}t |dd�D�]0\}‰t ‡‡fdd „t Dƒƒ}t t |ƒƒ ¡}tj d ˆ|¡tj d ˆ¡}| d ¡} | d ¡} |d pÖt} |d} | d¡} |ddu�rtjd|d<|d}| �r ddi|d<d|d <| �rBt| |dƒ|d <n0| �rr| �rdt| | || d�|d <nt| d�|d <| |¡| t|jˆfd|i|¤Ž¡qhtjd‰ttjdd�}tjd}ˆ�r"t‡fdd „|Dƒdƒ}|�rò|j |¡n.|j t|jdˆf|t|ƒd|dœ|¤Ž¡n||_t|jƒdk�r`|j t|jdtjf|d|dœ|¤Ž¡td|jƒ|_tjdƒS) NcSsTd||fd||dœgdd| ¡| ¡fig||dœ}|tvrP| t|¡|S)NzThe %s of the %s Galaxy serverzgalaxy_server.%s)Úsectionrnr?zANSIBLE_GALAXY_SERVER_%s_%s)r…ZiniÚenvrÄr¡)ÚupperÚSERVER_ADDITIONALrG)rArnrÄZ option_typeZ config_defrOrOrPÚserver_config_def\s þÿÿôz(GalaxyCLI.run..server_config_def)r³r´r:cSsg|] }|r|‘qSrOrO©riÚsrOrOrPr0xrlz!GalaxyCLI.run..r‡)Ústartc3s&|]\}}}|ˆˆ|||ƒfVqdS©NrO)riÚkÚreqZ ensure_type)rEÚ server_keyrOrPÚ }rlz GalaxyCLI.run..Z galaxy_serverr5r9r4r2r6r8rAz/v3ryr3)Z access_tokenr5r8r9)r4Úpriorityr—r›c3s|]}|jˆkr|VqdSrI©r?rF)Ú cmd_serverrOrPrM´rlZcmd_arg)r4rNr8rr<r·) r’rHÚrunr r�rrErJZGALAXY_SERVER_LISTÚ enumerateÚdictÚ SERVER_DEFr*r#Zget_single_datar¿Z+initialize_plugin_configuration_definitionsZget_plugin_optionsÚpopr rrrrGrrÚnextrxr]Z GALAXY_SERVERrvr‘)r{Zgalaxy_optionsZ optional_keyZconfig_serversZ server_listZserver_priorityZ config_dictZdefsZserver_optionsr5r9Z token_valr2r6r8Z cmd_tokenZ config_serverr”)rPrErLrPrQVs�      ý  ÿþý   ÿ ýü  ÿýü z GalaxyCLI.runcCs|jjSrI)r‘r|©r{rOrOrPr|Ðsz GalaxyCLI.apicCs tjdS)Nr)rJÚCOLLECTIONS_PATHSrWrOrOrPr4Ôsz&GalaxyCLI._get_default_collection_pathTc sžggdœ}tˆdd�}tj |¡s2tdtˆƒƒ‚t dˆ¡t|dƒ�Z}z t |ƒ}Wn<t y”} z$tdtˆƒt| ƒfƒ‚WYd} ~ n d} ~ 00Wdƒn1sª0Y|durÌtd tˆƒƒ‚‡‡fd d „} t |t ƒ�r|sòtd ƒ‚|D]} |d | | ƒ7<qönˆt | ¡ƒ t d dgƒ¡} | �rHtdtd | ¡ƒƒ‚| d ¡�pVgD]} |d | | ƒ7<�qX‡‡‡fdd„| d¡�p�gDƒ|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. )ÚrolesroÚsurrogate_or_strict©Úerrorsz*The requirements file '%s' does not exist.z Reading requirement file at '%s'ÚrbzIFailed to parse the requirements yml at '%s' with the following error: %sNz"No requirements found in file '%s'c s(d|vrTt |¡}t dt|ƒ¡d|vr.parse_role_req..css|]}t |¡VqdSrI)r+Úrole_yaml_parse)riÚirOrOrPrMrlzMGalaxyCLI._parse_requirements_file..parse_role_req..z9Unable to load data from include requirements file: %s %s)r+rarZÚvvvr'r rr�r‘r%rÁr^Úisfiler&Úopenr$rz)Z requirementrˆZb_include_pathZ f_includeÚe)Úrequirements_filer{rOrPÚparse_role_req s(  ÿ  ÿÿz:GalaxyCLI._parse_requirements_file..parse_role_reqzrExpecting requirements file to be a dict with the key 'collections' that contains a list of collections to installrYroz\Expecting only 'roles' and/or 'collections' as base keys in the requirements file. Found: %sz, cs g|]}t ˆ |¡ˆˆ¡‘qSrO)rZfrom_requirement_dictÚ_init_coll_req_dict)riZcollection_req)r@r{Úvalidate_signature_optionsrOrPr01s ûýz6GalaxyCLI._parse_requirements_file..)r%rÁr^Úexistsr r&rZrcrer$rÚ isinstancerƒÚsetr%Ú differenceÚjoinrF) r{rgÚallow_old_formatr@rjrãZb_requirements_fileZreq_objZfile_requirementsÚerrrhZrole_reqZ extra_keysrO)r@rgr{rjrPÚ_parse_requirements_file×sFþ    ÿÿ8  ÿú z"GalaxyCLI._parse_requirements_filecs‚tˆtƒsdˆiSdˆvs4ˆ d¡r4ˆ dd¡dkr8ˆStt‡fdd„|jDƒƒt|jdjˆdd�ˆdt j d d �ƒˆd<ˆS) Nr?rr¡r�c3s&|]}ˆd|j|jhvr|VqdS)rN)r?r—)riZsrvr©Úcoll_reqrOrPrMLsÿz0GalaxyCLI._init_coll_req_dict..zexplicit_requirement_{name!s}rOrA)r8) rlrSrFrVÚiterrxrr�r[rrE)r{rtrOrsrPri<s. ÿþý ÿÿúûzGalaxyCLI._init_coll_req_dictr‡cCstjdstdƒ‚dS)zn Exits with the specified return code unless the option --ignore-errors was specified rzR- you can use --ignore-errors to skip failed roles and finish processing the list.N)rrEr )ÚrcrOrOrPÚexit_without_ignore\s zGalaxyCLI.exit_without_ignorecCsäddt|dƒg}| di¡}| d| dd¡¡}| d|¡t| ¡ƒD]€}|tjvr^qNt||tƒr¸| d|¡t|| ¡ƒD]*}|tjvršqŠ| d||||f¡qŠqN| d |||f¡qN| d¡d   |¡S) Nr¬zRole: %sr?Ú galaxy_infor…z description: %sz %s:z %s: %sz %s: %sÚ ) r'rFrÚsortedr%rHÚSKIP_INFO_KEYSrlrSro)Ú role_infoÚtextrxr…rJrnrOrOrPÚ_display_role_infoes     zGalaxyCLI._display_role_infocCstj tj tj |¡¡¡SrI)rÁr^ÚabspathÚ expanduserÚ expandvars©r^rOrOrPrI�szGalaxyCLI._resolve_pathcstt|dd�dƒ� }t| ¡dd�}Wdƒn1s80Ytƒ}g}g}|D]r}| dd¡rh|n|}| |dd¡} | s´| dd¡} | dkršd } n| d kr¨g} n | d kr´i} | |d <| |¡qTt d ¡‰t d¡‰‡‡fdd„} t ƒ} t | ||dœd�} | | j j d<|   |¡}|S)NrZr[r]rÄFrnr¡r1r¬rƒrSrtzL\(([^)]+),\s+([^)]+)\)z C\(([^)]+)\)csJt|tƒrd dd„|Dƒ¡}ˆ d|¡}ˆ d|¡}tj|ddddd �S) Nz. cSsg|]}| d¡‘qSr6)Úrstrip)riÚlrOrOrPr0¤rlzKGalaxyCLI._get_skeleton_galaxy_yml..comment_ify..z\1 <\2>z'\1'éuz# F)ÚwidthÚinitial_indentÚsubsequent_indentZbreak_on_hyphens)rlrƒroÚsubÚtextwrapÚfill)Úv©Z const_patternZ link_patternrOrPÚ comment_ify¢s    z7GalaxyCLI._get_skeleton_galaxy_yml..comment_ify)Úrequired_configÚoptional_config©Z variablesrŽ)rer%r'Úreadr rFrrqr5r)r,Z environmentÚfiltersÚtemplate)Z template_pathÚ inject_dataZ template_objZ meta_templateZ galaxy_metar�r�Z meta_entryZ config_listrtZ meta_typerŽÚloaderÚtemplarÚ meta_valuerOr�rPÚ_get_skeleton_galaxy_yml…s4.       z"GalaxyCLI._get_skeleton_galaxy_ymlcsr|r|rtdƒ‚n\|s$|s$tdƒ‚nJ|rTˆdur8tdƒ‚t |¡}|j|dˆd�}n‡‡fdd„|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)rpr@csg|]}t |ˆˆ¡‘qSrO)rZ from_string)riZ coll_input©r@rrOrPr0ËsÿzFGalaxyCLI._require_one_of_collections_requirements..)rorY)r rHrIrr)r{rorgrr@rãrOršrPÚ(_require_one_of_collections_requirements³s*  ÿ ý þûz2GalaxyCLI._require_one_of_collections_requirementscCsdS)z˜ Perform the action on an Ansible Galaxy role. Must be combined with a further action like delete/install/init as listed below. NrOrWrOrOrPrÏ×szGalaxyCLI.execute_rolecCsdS)z— Perform the action on an Ansible Galaxy collection. Must be combined with a further action like init/install as listed below. NrOrWrOrOrPrÇßszGalaxyCLI.execute_collectioncCs”tjd}t tjd¡}t|dd�}tj |¡s>t |¡ntj  |¡rZt dt |ƒƒ‚tjdD]*}t |¡}t t |dd�t |dd�|ƒqddS)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¢r8rZr[z9- the output collection directory %s is a file - abortingrKN)rrErHrIr%rÁr^rkÚmakedirsrdr r&rr')r{r¢r8Ú b_output_pathr:rOrOrPr9çs        ýzGalaxyCLI.execute_buildcCs–tjd}tjd}tjd}tjd}|r6t |¡}|j|||d�d}t |¡}t|dd�}tj |¡svt  |¡t |||j |tjd |d�d S) r×rKrÞrßrã©r@rorZr[rår) rrErHrIr›r%rÁr^rkrœrrx)r{r@rorÞrßrgrãZb_download_pathrOrOrPrèþs,     þý     ýzGalaxyCLI.execute_downloadc%s¸tjd}tjd}tjd}tjd |¡}tjd |¡}td |¡tdƒd�}|d kr¤| td d d |tjd ddddtdd…gd� ¡tj}t j   ||¡}nV|dkrú|  dd¡\} } | t| | dddgdgddddgd� ¡tj }t j   || | ¡}t|dd�} t j  | ¡�r®t j  |¡�r4tdt|ƒƒ‚n|�sJtd t|ƒƒ‚t j| d!d"�D]T\} } }| D]}t j   | |¡}t |¡�qf|D]}t j   | |¡}t  |¡�qŠ�qX|du�r¾d#}nd!}|jj}d$g}t j  |¡}d%d&„|Dƒ‰t j  |¡�s td' t|ƒ|¡ƒ‚tƒ}t||d(�}t j  | ¡�s6t  | ¡t j|d!d"�D�]V\} } }t j  | |¡‰ˆ  t j¡}|d)}|dk�r�|d*v�oŒd+|v}n|d+k}‡fd,d&„| Dƒ| dd…<|D�]¤‰t j  ˆ¡\}}t ‡‡fd-d.„ˆDƒƒ�rê�q¶|dk�r”|�r”ˆdk�r”ˆd/k�r”| !¡}| "d0¡|d1<t# $t j   | ˆˆ¡|¡}tt j   |ˆ|¡dd�}t%|d2ƒ�"}| &t|dd�¡Wdƒn1�sˆ0YnÆ|d3k�r"|�s"t j   | ˆ¡}t j   |ˆ|¡}t'| (|¡d)dd�}t| )|¡dd�} t%|d2ƒ�}!|! &| ¡Wdƒn1�s0Yn8t j  t j   | ˆ¡|¡}"t *t j   | ˆ¡t j   ||"¡¡�q¶| D]6}#tt j   |ˆ|#¡dd�}$t j  |$¡�sbt  |$¡�qb�qDt+ +d4| ,¡|f¡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 ``.``. r¡rêr¢rìrízyour {0} descriptionzplugins/plugins.html)r…Zansible_plugin_list_dirrˆz your namezyour company (optional)z$license (GPL-2.0-or-later, MIT, etc)rîz http://example.com/issue/trackerzhttp://example.com/repositoryzhttp://docs.example.comzhttp://example.comNr‰) rZcompanyÚlicenser rîZissue_tracker_urlZrepository_urlZdocumentation_urlZ homepage_urlZmin_ansible_versionZ dependenciesrfr7r‡z1.0.0z README.mdzyour name zGPL-2.0-or-later) Ú namespaceÚcollection_namer`ZreadmeZauthorsrŸZ repositoryZ documentationZhomepageZissuesZ build_ignorerZr[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$cSsg|]}t |¡‘qSrO)rqr5)riÚxrOrOrPr0mrlz*GalaxyCLI.execute_init..z9- the skeleton path '{0}' does not exist, cannot init {1}r‘r)Z playbooksrYZ templatescs&g|]‰t‡fdd„ˆDƒƒsˆ‘qS)c3s|]}| ˆ¡VqdSrIr,r_©ÚdrOrPrM‡rlz4GalaxyCLI.execute_init...)Úany)ri)Úskeleton_ignore_rer¤rPr0‡rlc3s"|]}| tj ˆˆ¡¡VqdSrI)rrrÁr^ror_)ÚfÚrel_rootrOrPrMŒrlz)GalaxyCLI.execute_init..z galaxy.yml.j2r¡r?Úwbz.j2z - %s %s was created successfully)-rrEr[rSr/rGÚansible_versionrJZGALAXY_ROLE_SKELETON_IGNORErÁr^roÚsplitZ!GALAXY_COLLECTION_SKELETON_IGNOREr%rkrdr r&ÚwalkÚshutilÚrmtreeÚunlinkr�Zdefault_role_skeleton_pathr€r)r,rœÚrelpathÚsepÚsplitextr¦ÚcopyrUrHr™reÚwriter'Z_get_file_contentsr”ÚcopyfilerZÚtitle)%r{ròrêr¢Z obj_skeletonZobj_namer•Zskeleton_ignore_expressionsZobj_pathr r¡Z b_obj_pathÚrootÚdirsÚfilesZold_dirr^Zold_fileZ own_skeletonr–r—Zrel_dirsZ rel_root_dirZin_templates_dirÚfilenameÚextZ template_datar˜Z b_dest_fileZ galaxy_objZ src_templateZ dest_fileZ b_renderedZdfZ f_rel_pathr¥Z b_dir_pathrO)r¨r©r§rPrðsÒ   þ õõ ý  ÿ     $ 4 ,$zGalaxyCLI.execute_initc Cs€tjd}d}tjdD�]V}d|i}t|j|j|ƒ}|j}|rdd|vrZ|d|d<|d=| |¡tjd�sd}z|j |d ¡}Wn`t yæ}zH|j d krÂd |j vrÂd |}WYd}~�qrt d ||fƒ‚WYd}~n d}~00|rø| |¡nd |}�qrn"tjd�r*|j �s*d |}�qr|j�r>| |j¡tƒ} |  d|i¡} | �rb| | ¡|| |¡7}q| |¡dS)zx prints out detailed information about an installed role as well as info available from the galaxy API. r¯r¬rKr^r`Zinstalled_versionrªNFi�z Bad Requestú- the role %s was not foundz"Unable to find info about '%s': %srˆ)rrErr�r‘rarGr|Zlookup_role_by_namerZ http_codeÚmessager Ú_existsÚmetadatar+rar~Úpager) r{r¯Údatarˆr|rbraZ remote_datarfrKZ role_specrOrOrPr®sF    &   zGalaxyCLI.execute_infoc Cs tjd}tjd}tjd}tjd}tjd}tjd}|durLt|ƒ}|j||||d�d }d d „|Dƒ} t|| |j|||d �} td d„| DƒƒrœdSdS)rrKr²rrªrãrN©rr@rocSsg|]}tt |¡ƒ‘qSrO)rrHrI)rir^rOrOrPr0÷rlz,GalaxyCLI.execute_verify..)Úlocal_verify_onlyr@css|]}|js|VqdSrI)Úsuccess)riÚresultrOrOrPrMrlz+GalaxyCLI.execute_verify..r‡r)rrErƒr›rrxr¦) r{r@roZ search_pathsrrÄrgrrãZresolved_pathsÚresultsrOrOrPr!äs2      ýüüzGalaxyCLI.execute_verifycCstjd}tjd}d}tj d¡}|dur4t|ƒ}|rBt |¡}dt|ƒ}g}g}tjddkrªt tjd¡}|j||||d �} | d }| d r¦t  |  d ¡¡�n|s¾|dur¾t d ƒ‚|�rp|  d¡sà|  d¡sàt dƒ‚|j} |joúd| voúd| v} |j||| d�} | d }| d �r^|j�r:d| v�s:d| v�r^|j�rHtjntj } | |  d¡ƒn| ¡}| d }n.rzÜThe specified collections path '%s' is not part of the configured Ansible collections paths '%s'. The installed collection will not be picked up in an Ansible run, unless within a playbook-adjacent collections directory.ú:rZr[rª)rår@r+rª)rrEÚKeyErrorr‹r rFrJrXr]rZrÉr'rorr%rÁr^rkrœrrx)r{rãr^r@r¢rrÞr)r+rår*r²r8r�rOr‚rPrÌ_s@     ÿþ     ú z%GalaxyCLI._execute_install_collectionc Cstjd}tjd}tjd}tjdp*|}|D�]Ì}|rftjdrf|jtjdvrft d|j¡q0t d|j¡|jdu�r|jd|jks–|rì|rÆt d |j|jd|jp´d f¡| ¡n$t d |j|jd|jpàd f¡q0n|�st d t |ƒ¡q0z |  ¡}WnRt �yd}z8t d |jt |ƒf¡|  ¡WYd}~q0WYd}~n d}~00|�sâ|�râ|j�sŽt d|j¡�nT|j|j} | D�]@} t d| ¡tƒ} |  | ¡} t|j|jfi| ¤Ž} d| jv�rd| jv�r| jdu�r�qž| jdu�rF| |v�r4t dt | ƒ¡| | ¡nt d| j¡n˜| jd| jk�r¼|�r–t d| j| jd| j�pzd f¡|  ¡| | ¡n$t dt | ƒ| j|j| jdf¡n"|�rÎ| | ¡nt d| j¡�qž|s0t d|j¡|  ¡q0dS)NrãrÞr)r¢rKzSkipping role %szProcessing role %s r`z - changing role %s from %s to %sÚ unspecifiedzD- %s (%s) is already installed - use --force to change version to %sz$- %s is already installed, skipping.z(- %s was NOT installed successfully: %s z-Meta file %s is empty. Skipping dependencies.zInstalling dep %sr7z- adding dependency: %sz-- dependency %s already pending installation.z*- changing dependent role %s from %s to %szW- dependency %s (%s) from role %s differs from already installed version (%s), skippingz/- dependency %s is already installed, skipping.z$- %s was NOT installed successfully.r)rrEr?rZrcrar`rórÉr1r(r r'rwrÀr^Zmetadata_dependenciesrãÚdebugr+rarr�r‘r^Zscmr)r{rãZ role_filerÞZ force_depsr¢rˆZ installedrfZrole_dependenciesZdepZdep_reqZdep_infoZdep_rolerOrOrPrËŠs|     ÿ ÿ "    $   ÿ ÿ  zGalaxyCLI._execute_install_rolec Csštjdstdƒ‚tjdD]x}t|j|j|ƒ}z*| ¡rJt d|¡nt d|¡Wqty’}z t d|t |ƒfƒ‚WYd}~qd}~00qdS)zV removes the list of roles passed as arguments from the local system. rKz/- you must specify at least one role to remove.z- successfully removed %sz - %s is not installed, skipping.zFailed to remove role %s: %sNr) rrEr rr�r|rórZrzr r&)r{r rˆrfrOrOrPrõÜs ,zGalaxyCLI.execute_removecCs2tjddkr| ¡ntjddkr.| ¡dS)z5 List installed collections or roles r¡rˆrfN)rrEÚexecute_list_roleÚexecute_list_collectionrWrOrOrPrþðs zGalaxyCLI.execute_listc Csˆd}d}g}tjd}tjd}|D�]}t |¡}tj |¡rFd}n| d |¡¡q$|rÂt |j |j |tj  ||¡d�}tj |j¡r²d}t   dtj |j¡¡t|ƒ�qD| d|¡q$tj |¡sÞ| d |¡q$tj |¡sú| d |¡q$t   d|¡t |¡} | D]*} t |j |j | |d�}|j�rt|ƒ�qq$|�rT|�rTg}|D]} t  | ¡�qX|�s„td  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.r‚z# %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)rrErHrIrÁr^Úisdirrr[rr�r‘rorZÚdirnamercrkÚlistdirrÀrÉr ) r{Ú path_foundZ role_foundÚwarningsZroles_search_pathsr r^Z role_pathrbZ path_filesZ path_fileÚwrOrOrPrÓúsL         zGalaxyCLI.execute_list_rolec Csê|durd|_tjd}ttjdƒ}tjd}tj}i}g}d}d} |D�]$} t | ¡} tj   | ¡s‚| |vrpqJ|  d  | ¡¡qJtj   | ¡s |  d  | ¡¡qJd}|�r¶t|ƒ| d ¡\} } t| ƒ} ttj  | | | ¡d d �}tj   |¡sþ|  d   |¡¡qJtj   | ¡�s|  d  | ¡¡qJd} zt ||¡} Wn6t�yh}zt t|ƒ|¡WYd}~n d}~00|d v�rŠ| jd| jii|| <qJt| gƒ\}}t| dd||ƒt| ||ƒqJt| ƒ} tj   | ¡�rìt d  | ¡¡t t!| |ƒƒ}nt d  | ¡¡qJ|�st d  | ¡¡qJ|d v�r4dd„|Dƒ|| <qJt|ƒ\}}t| dd||ƒt"|t#d�D]} t| ||ƒ�q\qJ| �r‚|�r‚g}|D]}t $|¡�q†|�s²t%d  tjd¡ƒ‚|dk�rÎt t& '|¡¡n|dk�ræt t(|ƒ¡dS)zz List all collections installed on the local system :param artifacts_manager: Artifacts manager. NFrùr²rfrÕz=- the configured path {0}, exists, but it is not a directory.Tr7rZr[z(- unable to find {0} in collection paths>rûrür`Ú CollectionZVersionzSearching {0} for collectionsz/No 'ansible_collections' directory found at {0}zNo collections found at {0}cSsi|]}|jd|ji“qS)r`)rdre)rirfrOrOrPÚ Žsz5GalaxyCLI.execute_list_collection..rmrÖr¡rürûr))Zrequire_build_metadatarrErmr-rÀrHrIrÁr^rkrr[r×rr¬rr%rorZfrom_dir_path_as_unknownrsr(Z raise_fromr rdrerpr_rgrZrcrƒrrzr'rÉr rüÚdumpsr#)r{r@rùZcollections_search_pathsr¡Zdefault_collections_pathZcollections_in_pathsrÛrÚZcollection_foundr^r:r rfZb_collection_pathZval_errZ fqcn_widthZ version_widthrorÜrOrOrPrÔ2sœ       þ&  ÿÿ ÿ     z!GalaxyCLI.execute_list_collectioncCs8t tjd¡}tjd}tjd}t||j||ƒdS)zs Publish a collection into Ansible Galaxy. Requires the path to the collection tarball to publish. rKrr;N)rHrIrrErr|)r{r:rr:rOrOrPr<­s  zGalaxyCLI.execute_publishc Cs„d}d}tjdr"d tjd¡}|sLtjdsLtjdsLtjdsLtdƒ‚|jj|tjdtjdtjd|d �}|d d kr”tjd tjd �dSdg}|d |kr¾|  d|d |f¡n|  d|d ¡g}|dD]"}|  t |dd|dƒ¡qÜt |ƒ}d|}|  d¡|  |d¡|  |d¡|dD],}|  |d|d|df|df¡�q>d |¡}|  |¡d S)z0 searches for roles on the Ansible Galaxy serverièNrKrôrrrzYInvalid query. At least one search term, platform, galaxy tag or author must be provided.)rÚtagsrÚ page_sizeÚcountrzNo roles match your search.©Zcolorr‡r¬z6Found %d roles matching your search. Showing first %s.z$Found %d roles matching your search:rÇr2r7r?z %%-%ds %%s)ÚNameZ Description)z----z -----------ú%s.%sr…ry) rrEror r|Z search_rolesrZrJÚ COLOR_ERRORrr]r\rÁ) r{rárÿZresponserÂZmax_lenrˆZname_lenZ format_strrOrOrPr·s: "ÿ      *  zGalaxyCLI.execute_searchc Csdtjtjtjtjdœ}ttjddd�}ttjddd�}tjdrZ|jj||d�}�n |jj ||tjd tjd d �}t |ƒd k�rt j d ||fdd�t j dtj d�|D]4}t j d|ddd|dddftj d�q²t j d||ftj d�dSt   d|dd¡tjd�sft   d|dddd¡t   d|dd|ddf¡tjd�s~tjd�rg}d}|�s|jj|ddd�}|dddD]<}|d|v�r²t j |d ||d!d�|  |d¡�q²|dd"d#v�rd$}n t d%¡�q†dS)&z+ used to import a role into Ansible Galaxy Znormal)ÚINFOZWARNINGZERRORÚSUCCESSÚFAILEDr¤rZr[r§r )r¤r§rr )rr r‡zEWARNING: More than one Galaxy role associated with Github repo %s/%s.Zyellowrãz.The following Galaxy roles are being updated: rår†rˆr r?z[ To properly namespace this role, remove each of the above and re-import %s/%s from scratchrz(Successfully submitted import request %dÚidrz Role name: %sz Repo: %s/%sF)Ztask_idZ task_messagesZ message_textZ message_typeÚstate)rèréTrU)rJZ COLOR_WARNræÚCOLOR_OKr'rrEr|Zget_import_taskZcreate_import_taskr]rZZ COLOR_CHANGEDrÚtimeÚsleep) r{Zcolorsr¤r§Ztaskr€Zmsg_listÚfinishedÚmsgrOrOrPr àsTû  þÿ2ÿ "zGalaxyCLI.execute_importcCstjdrˆ|j ¡}t|ƒdkr.t d¡dStjdtjd�tjdtjd�|D]0}tjd|d|d |d |d ftjd�qRdStjd r¸|j tjd ¡tjd tjd�dStjd }tjd }tjd }tjd}|j  ||||¡}t d|d |d |d f¡dS)zD Setup an integration from Github or Travis for Ansible Galaxy rolesr rzNo integrations found.z ID Source Reporãz ---------- ---------- ----------z%-10s %-10s %s/%srêrr¤r§r zDSecret removed. Integrations using this secret will not longer work.rzAdded integration for %s %s/%s) rrEr|Z list_secretsr]rZrJrìZ remove_secretZ add_secret)r{Zsecretsrrr¤r§ÚresprOrOrPrs2    ÿÿ      zGalaxyCLI.execute_setupcCsŠtjd}tjd}|j ||¡}t|dƒdkrxt d¡t d¡t d¡|dD]}t d|j|j|jf¡qXt |d ¡d S) z$ Delete a role from Ansible Galaxy. r¤r§Z deleted_rolesr‡zDeleted the following roles:zID User Namez!------ --------------- ----------z %-8s %-15s %sÚstatusr) rrEr|Z delete_roler]rZrêr r?)r{r¤r§rñrˆrOrOrPr÷8s      zGalaxyCLI.execute_delete)N)N)N)N)N)N)N)N)N)N)N)N)N)TNT)r‡)NN)N)N)N)N)7r}r~rÚ__doc__r?r{r“rºrÈrÉrÐrÑrÍrÒrÓrÔrÕrÎrÌrÊrËr=rQr„r|r4rrriÚ staticmethodrwr~rIr™r›rÏrÇr9rTrèrðrr!r2rÌrËrõrþrÓrÔr<rr rr÷Ú __classcell__rOrOr”rPrHÆsx  U         ! Y  z  e     /ý $ 6  Y+R 8 z )7!rHcCst |¡dSrI)rHZ cli_executor)rKrOrOrPÚmainKsröÚ__main__)rUrV)rUrVrUrV)N)lZ __future__rrrr¡Z __metaclass__Z ansible.clirrRrüZos.pathrÁrqr®rŽrŠríÚtypingr€Z dataclassesrZ yaml.errorrZansible.constantsZ constantsrJZansiblerZansible.cli.argumentsr r»Zansible.errorsr r Zansible.galaxyr r Zansible.galaxy.apirrZansible.galaxy.collectionrrrrrrrrrZ3ansible.galaxy.collection.concrete_artifact_managerrZansible.galaxy.collection.gpgrZ0ansible.galaxy.dependency_resolution.dataclassesrZansible.galaxy.rolerZansible.galaxy.tokenrrrr Z$ansible.module_utils.ansible_releaser!r«Z'ansible.module_utils.common.collectionsr"Z ansible.module_utils.common.yamlr#r$Zansible.module_utils._textr%r&r'Zansible.module_utilsr(Zansible.parsing.dataloaderr)Zansible.parsing.yaml.loaderr*Z!ansible.playbook.role.requirementr+Zansible.templater,Zansible.utils.collection_loaderr-Zansible.utils.displayr.Zansible.utils.plugin_docsr/rZZmovesZurllibÚparseÚurlparserTrDrTr_rcrgrprurvrHrör}rOrOrOrPÚsŒ      ,                ü