관리-도구
편집 파일: play_iterator.cpython-39.pyc
a �����)g%y����������������������@���s����d�dl�mZmZmZ�eZd�dlZd�dlmZm Z �d�dl mZ�d�dl mZ�d�dlmZ�d�dlmZ�d�dlmZ�d�d lmZ�e��Zg�d �ZG�dd��de�ZG�d d��de �ZG�dd��d�ZG�dd��d�ZdS�)�����)�absolute_import�division�print_functionN)�IntEnum�IntFlag)� constants)�AnsibleAssertionError)�boolean)�Block)�Task)�Display)�PlayIterator�IteratingStates�FailedStatesc�������������������@���s$���e�Zd�ZdZdZdZdZdZdZdS�)r���r�����������������������N) �__name__� __module__�__qualname__�SETUP�TASKS�RESCUE�ALWAYS�HANDLERS�COMPLETE��r���r����B/usr/lib/python3.9/site-packages/ansible/executor/play_iterator.pyr���(���s���r���c�������������������@���s$���e�Zd�ZdZdZdZdZdZdZdS�)r���r���r���r���r�����������N) r���r���r����NONEr���r���r���r���r���r���r���r���r���r���1���s���r���c�������������������@���s<���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd S�)� HostStatec�����������������C���sv���|d�d���|�_�g�|�_d|�_d|�_d|�_d|�_d|�_tj|�_ t j|�_d�|�_ d|�_d|�_d�|�_d�|�_d�|�_d|�_d|�_d�S�)Nr���TF)�_blocks�handlers� cur_block�cur_regular_task�cur_rescue_task�cur_always_task�cur_handlers_taskr���r���� run_stater���r"���� fail_state�pre_flushing_run_state�update_handlers� pending_setup�tasks_child_state�rescue_child_state�always_child_state� did_rescue�did_start_at_task)�self�blocksr���r���r����__init__;���s"����zHostState.__init__c�����������������C���s ���d|�j��S�)Nz HostState(%r))r$����r5���r���r���r����__repr__O���s����zHostState.__repr__c�����������������C���sD���d|�j�|�j|�j|�j|�j|�j|�j|�j|�j|�j |�j |�j|�j|�j |�jf�S�)Na��HOST STATE: block=%d, task=%d, rescue=%d, always=%d, handlers=%d, run_state=%s, fail_state=%s, pre_flushing_run_state=%s, update_handlers=%s, pending_setup=%s, tasks child state? (%s), rescue child state? (%s), always child state? (%s), did rescue? %s, did start at task? %s)r&���r'���r(���r)���r*���r+���r,���r-���r.���r/���r0���r1���r2���r3���r4���r8���r���r���r����__str__R���s$������zHostState.__str__c�����������������C���s6���t�|t�sdS�dD�]}t|�|�t||�kr�dS�qdS�)NF)r$���r&���r'���r(���r)���r*���r+���r,���r-���r.���r/���r0���r1���r2���T)� isinstancer#����getattr)r5����other�attrr���r���r����__eq__h���s���� zHostState.__eq__c�����������������C���s���|�j�|�j�S��N)r$���r&���r8���r���r���r����get_current_blocku���s����zHostState.get_current_blockc�����������������C���s����t�|�j�}|�jd�d���|_|�j|_|�j|_|�j|_|�j|_|�j|_|�j|_|�j |_ |�j |_ |�j|_|�j|_|�j |_ |�j|_|�jd�ur�|�j���|_|�jd�ur�|�j���|_|�jd�ur�|�j���|_|S�r@���)r#���r$���r%���r&���r'���r(���r)���r*���r+���r,���r-���r.���r/���r3���r4���r0����copyr1���r2���)r5���Z new_stater���r���r���rB���x���s*���� zHostState.copyN) r���r���r���r7���r9���r:���r?���rA���rB���r���r���r���r���r#���:���s��� r#���c�������������������@���s����e�Zd�Zd4dd�Zdd��Zdd��Zd5dd �Zd d��Zdd ��Zdd��Z dd��Z dd��Zdd��Zdd��Z edd�dd�Zdd��Zdd��Zd d!��Zd"d#��Zd$d%��Zed&d'���Zeed(�d)d*�Zeedd+�d,d-�Zeedd.�d/d0�Zeedd1�d2d3�ZdS�)6r ���Fc�����������������C���sN��||�_�g�|�_||�_t|�j�d�}d|_t|d�}d|_d|_d|_i�|_ |�j�j sVdg|_ dD�]$} t|�j�| d��} | d�urZ| |j | <�qZ|�|�j�j ��|�j�jd�ur�|�j�jd�d���|_|g|_|�|�}|�j�|��|���|�_|�j����D�]2}|�|�}|���r�|�j�|��|�j�|�����q�d d ��|�j�jD��|�_i�|�_d} |j|�j�j|�j�jd�}t|�|�_|D�]�}|��|jt |�jd���|j!d�u�rT|�sT|�j"|d d�\}}|j#t$j%k�r��q |j|j!k�s�|j�r�t&�&|j|j!��s�|�'��|j!k�s�t&�&|�'��|j!��r�d } �q |��|j|���q�| �rTd |�j|j�_(t$j)|�j|j�_#�qT| �r>d�|_!d|�_*d|�_+d�S�)N)�playF��block�gather_factszansible.builtin.gather_factszGathering Facts�always)Z gather_subsetZgather_timeoutZ fact_pathc�����������������S���s���g�|�]}|j�D�]}|�qqS�r���rD�����.0�b�hr���r���r���� <listcomp>���������z)PlayIterator.__init__.<locals>.<listcomp>)�order�r6���T)�peekr���),�_playr$����_variable_managerr ���Zrun_oncer����actionZresolved_action�name�args�tagsr<���� set_loaderZ_loaderZ_included_conditionalZwhenrE���Zfilter_tagged_tasks�appendZ get_tasksZ all_tasks�compile� has_tasks�extendr%����_host_statesZ get_hosts�hostsrN����lenZ batch_size�set_state_for_hostr#���Z start_at_task�get_next_task_for_hostr+���r���r����fnmatchZget_namer4���r���Zend_playZcur_task)r5���Z inventoryrC���Zplay_contextZvariable_managerZall_varsZ start_at_done�setup_blockZ setup_task�option�valuerE���Z new_blockZstart_at_matchedZbatch�host�s�taskr���r���r���r7�������sl���� (��zPlayIterator.__init__c�����������������C���s0���|j�|�jvr |��|j�tg�d���|�j|j�����S�)NrO���)rT���r\���r_���r#���rB����r5���re���r���r���r����get_host_state����s����zPlayIterator.get_host_statec�����������������C���s���t�jddd��d�S�)NzlPlayIterator.cache_block_tasks is now noop due to the changes in the way tasks are cached and is deprecated.�H�z�G@��version��displayZ deprecated)r5���rE���r���r���r����cache_block_tasks����s�����zPlayIterator.cache_block_tasksc�����������������C���s����t��d|j���|��|�}d�}|jtjkrBt��d|j���|d�fS�|�j||d�\}}|sf|��|j|��t��d|j���t��d|���t��d|���||fS�)Nz!getting the next task for host %sz$host %s is done iterating, returning�re���z"done getting next task for host %sz ^ task is: %sz ^ state is: %s) rn����debugrT���ri���r+���r���r����_get_next_task_from_stater_���)r5���re���rP���rf���rg���r���r���r���r`�������s���� z#PlayIterator.get_next_task_for_hostc�����������������C���s:��d�}z|j�|j�}W�n"�ty6���tj|_|d�f�Y�S�0�|jtjk�r6|js�d|_tj }|�j jd�u�prt|�j jdd�}|dkr�|s�|dkr�t|�j jdd�s�|dkr�|r�|�j j�|ji���dd�s�|�j�d�}|���r�t|j�dkr�|jd�}nHd|_tj|_|j�s(|�jd 7��_d|_d|_d|_d�|_d�|_d�|_�n�|jtjk�r,|j�rRd|_|j�r�|�j|j|d �\|_}|��|j��r�d�|_|��|��n"|d�u��s�|jjtjk�r(d�|_qnt|��|��r�tj|_n^|jt|j�k�r�tj |_nB|j|j�}t!|t"��rt#|gd�|_tj|j_d�}|�jd 7��_�n�|jtjk�r:|j�r�|�j|j|d �\|_}|��|j��rxd�|_|��|��n"|d�u��s�|jjtjk�r6d�|_qn�|j$t%j@�t%jk�r�tj |_n||jt|j&�k�r�t|j&�dk�r�t%j'|_$tj |_d|_(nB|j&|j�}t!|t"��r(t#|gd�|_tj|j_d�}|�jd 7��_�n�|jtj k�rZ|j�r�|�j|j|d �\|_}|��|j��r�d�|_|��|��n"|d�u��s�|jjtjk�rXd�|_qn�|jt|j)�k�r|j$t%j'k�r�tj|_n@|�jd 7��_d|_d|_d|_tj|_d�|_d�|_d�|_d|_(nB|j)|j�}t!|t"��rJt#|gd�|_tj|j_d�}|�jd 7��_n�|jtj*k�r|j+�r�|�j,d�d���|_,d|_+d|_-|j$t%j*@�t%j*k�r�d|_+tj|_n`z|j,|j-�}W�n,�t�y����d�}|j.|_d|_+Y��q(Y�n 0�|�j-d 7��_-|�/|��r��q(�q�n|jtjk�r(|d�fS�|r�q2q||fS�)NTF)�strictZimplicitZexplicitZsmartZ_ansible_facts_gatheredr���r���rp���rO���)0r$���r&���� IndexErrorr���r���r+���r���r/����CZDEFAULT_GATHERINGrQ���rF���r ���rR���Z_fact_cache�getrT���rZ���r^���rE���r���r4���r'���r(���r)���r0���r1���r2���rr����_check_failed_state�_set_failed_stater���r���r;���r ���r#���r,���r����rescuer"���r3���rG���r���r.���r%���r*���r-���Zis_host_notified)r5����statere���rg���rE���Z gatheringZimpliedrb���r���r���r���rr�����s��������� z&PlayIterator._get_next_task_from_statec�����������������C���s���|j�tjkr(|�jtjO��_tj|_��nl|j�tjkr�|jd�urN|��|j�|_nH|�jtjO��_|j |j �jrvtj|_�n |j |j �j r�tj|_�ntj|_�n�|j�tjkr�|jd�ur�|��|j�|_n0|�jtjO��_|j |j �j r�tj|_�ntj|_�n�|j�tjk�r4|jd�u�r|��|j�|_n|�jtjO��_tj|_�n`|j�tjk�r�|�jtjO��_d|_|j |j �j�rrtj|_�n"|j |j �j �r�tj|_�ntj|_�|S�)NT)r+���r���r���r,���r���r���r���r0���rx���r$���r&���ry���r���rG���r���r1���r2���r���r.����r5���rz���r���r���r���rx������sB���� zPlayIterator._set_failed_statec�����������������C���sV���|���|�}t�d||f���|��|�}t�d|���|��|j|��|�jj�|j��d�S�)Nz)marking host %s failed, current state: %sz^ failed state is now: %s) ri���rn���rq���rx���r_���rT���rQ���Z_removed_hostsrX����r5���re���rf���r���r���r����mark_host_failed���s���� zPlayIterator.mark_host_failedc��������������������s���t���fdd���j���D���S�)Nc�����������������3���s$���|�]\}}����|�r|d�fV��qdS�)TN)rw���)rI���re���rz���r8���r���r���� <genexpr>��rM���z0PlayIterator.get_failed_hosts.<locals>.<genexpr>)�dictr\����itemsr8���r���r8���r����get_failed_hosts��s����zPlayIterator.get_failed_hostsc�����������������C���s"��|d�u�rdS�|j�tjkr(|��|j�r(dS�|j�tjkrD|��|j�rDdS�|j�tjkrf|jt j@�t jkrfdS�|jt j kr�|j�tjkr�|jt j@�dkr�dS�|j�tjkr�|jt j@�dkr�dS�|jo�|jt j@�dk�S�nR|j�tjk�r|��|j ��r|j|j�}t|j�dk�r|jt j@�dk�rdS�dS�dS�)NFTr���)r+���r���r���rw���r1���r���r2���r���r,���r���r"���r3���r���r0���r$���r&���r^���ry���)r5���rz���r&���r���r���r���rw�����s(����"z PlayIterator._check_failed_statec�����������������C���s���|���|�}|��|�S�r@���)ri���rw���r|���r���r���r���� is_failed��s���� zPlayIterator.is_failedc�����������������C���s���|���|��|j���d�S�r@���)�_clear_state_errors�get_state_for_hostrT���rh���r���r���r����clear_host_errors ��s����zPlayIterator.clear_host_errorsN)rz����returnc�����������������C���sR���t�j|_|jd�ur |��|j��n.|jd�ur8|��|j��n|jd�urN|��|j��d�S�r@���)r���r"���r,���r0���r����r1���r2���r{���r���r���r���r����#��s���� z PlayIterator._clear_state_errorsc�����������������C���sj���|j�tjkr"|jdur"|��|j�S�|j�tjkrD|jdurD|��|j�S�|j�tjkrf|jdurf|��|j�S�|S�)z_ Finds the active state, recursively if necessary when there are child states. N) r+���r���r���r0����get_active_stater���r1���r���r2���r{���r���r���r���r����-��s����zPlayIterator.get_active_statec�����������������C���s`���|j�tjkr|���jrdS�|jdur0|��|j�S�|jdurF|��|j�S�|jdur\|��|j�S�dS�)z� Given the current HostState state, determines if the current block, or any child blocks, are in rescue mode. TNF) r+���r���r���rA���ry���r0����is_any_block_rescuingr1���r2���r{���r���r���r���r����9��s���� z"PlayIterator.is_any_block_rescuingc�����������������C���s���t�jddd��dS�)NzlPlayIterator.get_original_task is now noop due to the changes in the way tasks are cached and is deprecated.rj���rk���)NNrm���)r5���re���rg���r���r���r����get_original_taskH��s �����zPlayIterator.get_original_taskc�����������������C���s���|j�tjkr|jtjks|s |S�|jtjkr�|jrD|��|j|�|_nJ|j|j �� ��}|jd�|j��}|j|jd���}||�|�|_||j|j <��n|jtj k�r|jr�|��|j|�|_nJ|j|j �� ��}|jd�|j��}|j|jd���}||�|�|_||j|j <�n�|jtjk�rx|j�r,|��|j|�|_nJ|j|j �� ��}|jd�|j��}|j|jd���}||�|�|_||j|j <�n*|jtjk�r�dd��|D��|j|j|j�<�|S�)Nc�����������������S���s���g�|�]}|j�D�]}|�qqS�r���rD���rH���r���r���r���rL���q��rM���z9PlayIterator._insert_tasks_into_state.<locals>.<listcomp>)r,���r���r"���r+���r���r���r0����_insert_tasks_into_stater$���r&���rB���rE���r'���r���r1���ry���r(���r���r2���rG���r)���r���r%���r*���)r5���rz���� task_listZtarget_block�beforeZafterr���r���r���r����P��s:����z%PlayIterator._insert_tasks_into_statec�����������������C���s ���|���|j|��|��|�|���d�S�r@���)r_���rT���r����ri���)r5���re���r����r���r���r���� add_tasksu��s����zPlayIterator.add_tasksc�����������������C���s���|�j�S�r@����r\���r8���r���r���r����host_statesx��s����zPlayIterator.host_states)�hostnamer����c�����������������C���s ���|�j�|�S�r@���r����)r5���r����r���r���r���r����|��s����zPlayIterator.get_state_for_host)r����rz���r����c�����������������C���s(���t�|t�stdt|����||�j|<�d�S�)Nz-Expected state to be a HostState but was a %s)r;���r#���r����typer\���)r5���r����rz���r���r���r���r_�����s���� zPlayIterator.set_state_for_host)r����r+���r����c�����������������C���s*���t�|t�stdt|����||�j|�_d�S�)Nz5Expected run_state to be a IteratingStates but was %s)r;���r���r���r����r\���r+���)r5���r����r+���r���r���r����set_run_state_for_host���s���� z#PlayIterator.set_run_state_for_host)r����r,���r����c�����������������C���s*���t�|t�stdt|����||�j|�_d�S�)Nz3Expected fail_state to be a FailedStates but was %s)r;���r���r���r����r\���r,���)r5���r����r,���r���r���r����set_fail_state_for_host���s���� z$PlayIterator.set_fail_state_for_host)F)F)r���r���r���r7���ri���ro���r`���rr���rx���r}���r����rw���r����r����r#���r����r����r����r����r����r�����propertyr�����strr����r_���r���r����r���r����r���r���r���r���r �������s0��� V �E) % r ���)Z __future__r���r���r���r����Z __metaclass__ra����enumr���r���Zansibler���ru���Zansible.errorsr���Z)ansible.module_utils.parsing.convert_boolr ���Zansible.playbook.blockr ���Zansible.playbook.taskr���Zansible.utils.displayr���rn����__all__r���r���r#���r ���r���r���r���r����<module>���s��� V