o nnhq*@sddlmZddlmZddlZddlZddlmZddlm Z ddl m Z ddl mZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZmZddlmZeZGdddeZdddZ e!dkrqe dSdS)) annotations)CLIN) constants)context)option_helpers) AnsibleError)PlaybookExecutor)to_bytes)Block)add_all_plugin_dirs)AnsibleCollectionConfig)_get_collection_name_from_path_get_collection_playbook_path)DisplaycsHeZdZdZdZfddZfddZfddZed 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|jdddt|jt|jt|jt|jt |jt |jt |jt |jt |jt|j|jjddddd|jjd d dd d|jjd d ddd|jjddddd|jjdddd|jjddddddS)Nz,%prog [options] playbook.yml [playbook2 ...]zJRuns Ansible playbooks, executing the defined tasks on the targeted hosts.)usagedescz--syntax-checksyntax store_truez=perform a syntax check on the playbook, but do not execute it)destactionhelpz --list-tasks listtasksz%list all tasks that would be executedz --list-tagslisttagszlist all available tagsz--stepstepz4one-step-at-a-time: confirm each task before runningz--start-at-task start_at_taskz1start the playbook at the task matching this name)rrargsz Playbook(s)playbook+)rmetavarnargs)superr init_parseropt_helpadd_connect_optionsparseradd_meta_optionsadd_runas_optionsadd_subset_optionsadd_check_optionsadd_inventory_optionsadd_runtask_optionsadd_vault_optionsadd_fork_optionsadd_module_options add_argument)self __class__?/usr/local/lib/python3.10/dist-packages/ansible/cli/playbook.pyr"%s<                zPlaybookCLI.init_parsercsPt|jp|j}tt||}|jr|sddg|_|jt_|j |ddd|S)NneverallT) runas_opts fork_opts) booltags skip_tagsr!rpost_process_argsr verbositydisplayvalidate_conflicts)r0optionshavetagsr1r3r4r<Ds zPlaybookCLI.post_process_argsc sNtt|d}d}i}g}tjdD]M}t|}|dur#|d}n%tj|s/t d|tj |sDt t |j sDt d|t|}|satjtjt|dd}t|||q|rg|t_tjdstjdstjd stjd s|\}}||d }|\} } } t| tjd tjd r|| | ttjd| | | |d} | } t| tr| D]}td|dt|dD]\}}|j dur| !|j ntj"tj|d}| !|zd#|j$}Wn t%yd}Ynwd|d||j&f}t'|j(|dd#7}tjdr._process_block)playz TASK TAGS: [%s] rSr)1r!rrunrrZrospathexistsrisfilestatS_ISFIFOst_moder dirnameabspathr r appendr playbook_paths ask_passwords _play_prereqsr get_host_list _flush_cacherrUr[r> enumerate_included_path set_basedirrealpathrahosts TypeErrorr_r]r: get_hostslenget_varscompilefilter_tagged_tasks has_tasksr\r^)r0sshpass becomepassrNb_playbook_dirsrresourceplaybook_collectionb_playbook_dirrMrKrLpbexresultspidxrjpb_dir host_listmsg playhostshostrcall_varsrTrer1rfr4rkWs                        BzPlaybookCLI.runcCs$|D] }|}||qdSN) list_hostsr` clear_facts)rKrLrhostnamer3r3r4rzs  zPlaybookCLI._flush_cache) __name__ __module__ __qualname____doc__r_r"r<rk staticmethodrz __classcell__r3r3r1r4rs   rcCst|dSr)r cli_executor)rr3r3r4mainsr__main__r)" __future__r ansible.clirrlrpansiblerrVransible.cli.argumentsrr#ansible.errorsr"ansible.executor.playbook_executorr+ansible.module_utils.common.text.convertersr ansible.playbook.blockr ansible.plugins.loaderr ansible.utils.collection_loaderr 2ansible.utils.collection_loader._collection_finderr ransible.utils.displayrr>rrrr3r3r3r4s,             P