관리-도구
편집 파일: playbook.cpython-39.pyc
a �����)g�(����������������������@���s����d�dl�mZmZmZ�eZd�dlmZ�d�dlZd�dl Z d�dl mZ�d�dl m Z �d�dlmZ�d�dlmZ�d�dlmZ�d�d lmZ�d�d lmZ�d�dlmZ�d�dlmZ�d�d lmZmZ�d�dl m!Z!�e!��Z"G�dd��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)�Displayc�����������������������sH���e�Zd�ZdZdZ��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-playbookc��������������������s��t�t|��jddd��t�|�j��t�|�j��t�|�j��t�|�j��t� |�j��t� |�j��t�|�j��t�|�j��t� |�j��t�|�j��|�jjddddd��|�jjd d ddd��|�jjdd ddd��|�jjddddd��|�jjdddd��|�jjddddd��d�S�)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)r���r����argszPlaybook(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_parserc��������������������s,���t�t|���|�}|jt_|�j|ddd��|S�)NT)Z runas_optsZ fork_opts)r!���r����post_process_args� verbosity�displayZvalidate_conflicts)r&����optionsr'���r)���r*���r+���E���s����zPlaybookCLI.post_process_argsc�������������� ������sh��t�t|������d�}d�}i�}g�}tjd�D�]�}t|�}|d�urF|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 d�u�r�| �!|j ��n"tj�"tj�|d���}| �!|��zd�#|j$�}W�n�t%�y���d}Y�n0�d|d�||j&f�}t'|j(��|dd�#���7�}tjd��r�t'| �)|j$��}|d|j$t*|�f�7�}|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�| S�d�S�) Nr�������z#the playbook: %s could not be foundz-the playbook: %s does not appear to be a fileZsurrogate_or_strict)�errorsZ listhostsr���r���r���)Z conn_passZbecome_passZsubsetZflush_cache)Z playbooks� inventory�variable_manager�loader� passwordsz playbook: %sr���Zplays�,��z play #%d (%s): %s����z TAGS: [%s]z pattern: %s hosts (%d):z %sz tasks: c��������������������s����d}|�j�D�]�}t|t�r&|��|�7�}q |jtjv�r:|jr:q ��|j��t j d�r t��t |j���}|����|jr�|d|����7�}n|d|j�7�}|dd�|��7�}q |S�)Nr6���r���z %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.<locals>._process_block)�playz TASK TAGS: [%s] r8���r���)1r!���r����runr���r>���r����os�path�existsr ����isfile�stat�S_ISFIFO�st_moder����dirname�abspathr���r ����appendr���Zplaybook_pathsZ ask_passwordsZ _play_prereqsr���Z get_host_list�_flush_cacher ���r:���r?���r-���� enumerateZ_included_pathZset_basedir�realpathrE����hosts� TypeErrorrC���rA���r=���Z get_hosts�lenZget_vars�compileZfilter_tagged_tasksZ has_tasksr@���rB���)r&���ZsshpassZ becomepassr4���Zb_playbook_dirsr����resourceZplaybook_collectionZb_playbook_dirr3���r1���r2���Zpbex�results�p�idxrK���Zpb_dirZ host_list�msgZ playhosts�hostrG���Zall_varsr9���rH���r'���rI���r*���rL���M���s����� �� � zPlaybookCLI.runc�����������������C���s$���|�����D�]}|���}|�|��qd�S��N)Z list_hostsrD���Zclear_facts)r1���r2���rc����hostnamer)���r)���r*���rW�������s����zPlaybookCLI._flush_cache)�__name__� __module__�__qualname__�__doc__rC���r"���r+���rL����staticmethodrW���� __classcell__r)���r)���r'���r*���r��� ���s����r���c�����������������C���s���t��|���d�S�rd���)r���Zcli_executor)r���r)���r)���r*����main����s����rl����__main__)N)&Z __future__r���r���r����typeZ __metaclass__Zansible.clir���rM���rQ���Zansibler���r;���r���Zansible.cli.argumentsr���r#���Zansible.errorsr ���Z"ansible.executor.playbook_executorr ���Zansible.module_utils._textr���Zansible.playbook.blockr���Zansible.plugins.loaderr ���Zansible.utils.collection_loaderr���Z2ansible.utils.collection_loader._collection_finderr���r���Zansible.utils.displayr���r-���r���rl���rf���r)���r)���r)���r*����<module>���s*����E