a ì)gÿ(ã@sîddlmZmZmZeZddlmZddlZddl Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZmZddl m!Z!e!ƒZ"Gdd„deƒZ#ddd„Z$e%dkrêe$ƒdS)é)Úabsolute_importÚdivisionÚprint_function)ÚCLIN)Ú constants)Úcontext)Úoption_helpers)Ú AnsibleError)ÚPlaybookExecutor)Úto_bytes)ÚBlock)Úadd_all_plugin_dirs)ÚAnsibleCollectionConfig)Ú_get_collection_name_from_pathÚ_get_collection_playbook_path)ÚDisplaycsHeZdZdZdZ‡fdd„Z‡fdd„Z‡fdd„Zed d „ƒZ ‡Z S) Ú PlaybookCLIz´ the tool to run *Ansible playbooks*, which are a configuration and multinode deployment system. See the project home page (https://docs.ansible.com) for more information. zansible-playbookcstt|ƒjddd�t |j¡t |j¡t |j¡t |j¡t  |j¡t  |j¡t  |j¡t  |j¡t  |j¡t |j¡|jjddddd�|jjd d dd d�|jjd d ddd�|jjddddd�|jjdddd�|jjddddd�dS)Nz,%prog [options] playbook.yml [playbook2 ...]zJRuns Ansible playbooks, executing the defined tasks on the targeted hosts.)ÚusageZdescz--syntax-checkÚsyntaxÚ store_truez=perform a syntax check on the playbook, but do not execute it)ÚdestÚactionÚhelpz --list-tasksÚ listtasksz%list all tasks that would be executedz --list-tagsÚlisttagszlist all available tagsz--stepÚstepz4one-step-at-a-time: confirm each task before runningz--start-at-taskZ start_at_taskz1start the playbook at the task matching this name)rrÚargsz Playbook(s)Úplaybookú+)rÚmetavarÚnargs)ÚsuperrÚ init_parserÚopt_helpZadd_connect_optionsÚparserZadd_meta_optionsZadd_runas_optionsZadd_subset_optionsZadd_check_optionsZadd_inventory_optionsZadd_runtask_optionsZadd_vault_optionsZadd_fork_optionsZadd_module_optionsÚ add_argument)Úself©Ú __class__©ú8/usr/lib/python3.9/site-packages/ansible/cli/playbook.pyr"&s< þ           ÿ ÿ ÿ ÿ ÿzPlaybookCLI.init_parsercs,tt|ƒ |¡}|jt_|j|ddd�|S)NT)Z runas_optsZ fork_opts)r!rÚpost_process_argsÚ verbosityÚdisplayZvalidate_conflicts)r&Úoptionsr'r)r*r+EszPlaybookCLI.post_process_argsc shtt|ƒ ¡d}d}i}g}tjdD]š}t|ƒ}|durF|d}nJtj |¡s^t d|ƒ‚tj  |¡sˆt   t  |¡j ¡sˆt d|ƒ‚t|ƒ}|s(tj tj t|dd�¡¡}t|ƒ| |¡q(|rÎ|t_tjd�stjd�stjd �stjd �s| ¡\}}||d œ}| ¡\} } } t | tjd ¡tjd �rL| | | ¡ttjd| | | |d�} |  ¡} t| tƒ�r`| D�]Ü}t d|d¡t|dƒD�]´\}}|j du�rÄ|  !|j ¡n"tj "tj |d¡¡}|  !|¡zd #|j$¡}Wnt%�yd}Yn0d|d||j&f}t'|j(ƒ‰|dd #ˆ¡7}tjd�rŠt'|  )|j$¡ƒ}|d|j$t*|ƒf7}|D]}|d|7}�qvt |¡t'ƒ‰tjd �s²tjd�r d}tjd�rÆd}‡‡‡fdd„‰| j+|d�}| ,¡D]*}| -|¡}| .¡�s�qê|ˆ|ƒ7}�qêtjd �rJtˆ /ˆ¡ƒ}| 0¡|dd #|¡7}t |¡�q �q|dS| SdS) Nréz#the playbook: %s could not be foundz-the playbook: %s does not appear to be a fileZsurrogate_or_strict)ÚerrorsZ listhostsrrr)Z conn_passZ become_passZsubsetZ flush_cache)Z playbooksÚ inventoryÚvariable_managerÚloaderÚ passwordsz playbook: %srZplaysú,Úz play #%d (%s): %séz TAGS: [%s]z pattern: %s hosts (%d):z %sz tasks: csªd}|jD]š}t|tƒr&|ˆ|ƒ7}q |jtjvr:|jr:q ˆ |j¡t j dr t ˆ  t |jƒ¡ƒ}| ¡|jr„|d| ¡7}n|d|j7}|dd |¡7}q |S)Nr6rz %sz TAGS: [%s] ú, )ÚblockÚ isinstancer rÚCZ _ACTION_METAZimplicitÚupdateÚtagsrÚCLIARGSÚlistÚunionÚsetÚsortÚnameÚget_nameÚjoin)ÚbÚtaskmsgZtaskÚcur_tags©Ú_process_blockZall_tagsZmytagsr)r*rJ¶s    z'PlaybookCLI.run.._process_block)Úplayz TASK TAGS: [%s] r8r)1r!rÚrunrr>rÚosÚpathÚexistsr ÚisfileÚstatÚS_ISFIFOÚst_moderÚdirnameÚabspathr r ÚappendrZplaybook_pathsZ ask_passwordsZ _play_prereqsrZ get_host_listÚ _flush_cacher r:r?r-Ú enumerateZ_included_pathZ set_basedirÚrealpathrEÚhostsÚ TypeErrorrCrAr=Z get_hostsÚlenZget_varsÚcompileZfilter_tagged_tasksZ has_tasksr@rB)r&ZsshpassZ becomepassr4Zb_playbook_dirsrÚresourceZplaybook_collectionZb_playbook_dirr3r1r2ZpbexÚresultsÚpÚidxrKZpb_dirZ host_listÚmsgZ playhostsÚhostrGZall_varsr9rHr'rIr*rLMs˜     ÿÿ     þ              zPlaybookCLI.runcCs$| ¡D]}| ¡}| |¡qdS©N)Z list_hostsrDZ clear_facts)r1r2rcÚhostnamer)r)r*rWÝs zPlaybookCLI._flush_cache) Ú__name__Ú __module__Ú __qualname__Ú__doc__rCr"r+rLÚ staticmethodrWÚ __classcell__r)r)r'r*r s   rcCst |¡dSrd)rZ cli_executor)rr)r)r*ÚmainäsrlÚ__main__)N)&Z __future__rrrÚtypeZ __metaclass__Z ansible.clirrMrQZansiblerr;rZansible.cli.argumentsrr#Zansible.errorsr Z"ansible.executor.playbook_executorr Zansible.module_utils._textr Zansible.playbook.blockr Zansible.plugins.loaderr Zansible.utils.collection_loaderrZ2ansible.utils.collection_loader._collection_finderrrZansible.utils.displayrr-rrlrfr)r)r)r*Ús*           E