%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/ansible/executor/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/ansible/executor/__pycache__/playbook_executor.cpython-39.pyc

a

�)g�:�@s�ddlmZmZmZeZddlZddlmZ	ddlm
Z
ddlmZm
Z
ddlmZddlmZddlmZmZmZdd	lmZdd
lmZddlmZddlmZdd
lmZm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&e&�Z'Gdd�d�Z(dS)�)�absolute_import�division�print_functionN)�	constants)�context)�TaskQueueManager�AnsibleEndPlay)�to_text)�boolean)�
become_loader�connection_loader�shell_loader)�Playbook)�Templar)�
pct_to_int)�AnsibleCollectionConfig)�_get_collection_name_from_path�_get_collection_playbook_path)�
makedirs_safe)�set_default_transport)�Displayc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�PlaybookExecutorzw
    This is the primary class for executing playbooks, and thus the
    basis for bin/ansible-playbook operation.
    cCs�||_||_||_||_||_t�|_tj�	d�sVtj�	d�sVtj�	d�sVtj�	d�r^d|_
nt||||jtj�	d�d�|_
t�dS)NZ	listhostsZ	listtasksZlisttags�syntax�forks)�	inventory�variable_manager�loader�	passwordsr)
�
_playbooks�
_inventory�_variable_manager�_loaderr�dict�_unreachable_hostsr�CLIARGS�get�_tqmrr)�selfZ	playbooksrrrr�r(�F/usr/lib/python3.9/site-packages/ansible/executor/playbook_executor.py�__init__2s(
�
�
�zPlaybookExecutor.__init__c$Cs�d}g}i}�zbttjdd��ttjdd��ttjdd��|jD�]�}t|�}|durn|d}|d}n|}t|�}|r�t�	d�
|��|t_ndt_t
j||j|jd�}|jdur�d	|i}g|d
<n|j��|j�d|�d}	|��}
t�dt|
�t|�f�|
D�]}|jdu�r0|j�|j�n|j�|j�|j��|jj|d
�}t|j|d�}
t|d|
� |j!��|j!�r^|j!D]�}|d}|�"d|�}|�"dd�}t#|�"dd��}t#|�"dd��}|�"dd�}|�"dd�}|�"dd�}|�"dd�}||jj$v�r�|j�rP|j�d|||||||||�
t�%|||||||||�	|j&|<n
||j&|<�q�|jj|d
�}t|j|d�}
|�'|
�t(j)d�r��q|jdu�r�|d
�*|��n`|jj+�,|j+�t|jj-�}t|jj+�}d}|�.|�}t|�dk�r|j�d|�|j�d�|D]�}|j�/|�z|jj0|d
�}Wn<t1�yr}z"|j2}WYd}~�qWYd}~n
d}~00||jj3@dk�r�|jj4}d}t|jj-�t|jj+�||}t|�|k�r�d}�q|t|jj-�|7}|t|jj+�|7}|j+�,|jj+��q|�r�q|	d}	�q|�r.|�*|�|jdu�rt5j6�r�t7|jj-�8��}|�,|jj+�8��t9|�}t|�dk�r�t5j:�r�t5j:} n |�r�t;j<�=t;j<�>|��} nd} t;j<�?t;j<�@|��\}!}"t;j<�A| d|!�}#|�B|#|��r�t�d |#�|j�d!|jjC�|dkrF�qqF|�rF|W|jdu�r2|j�D�|j�rD|j�E�SW|jdu�r^|j�D�|j�r�|j�E�n*|jdu�r�|j�D�|j�r�|j�E�0t(j)d�r�t�d"�|St(j)d#�r�|jjF�s�t�Gd$t(j)d#�|S)%z�
        Run the given playbook, based on the settings in the play which
        may limit the runs to serialized groups, etc.
        rT)Z
class_onlyN��z&running playbook inside collection {0})rr�playbook�playsZv2_playbook_on_startz%d plays in %s)�play)rZ	variables�vars_prompt�name�prompt�default�private�confirmF�encrypt�	salt_size�salt�unsafeZv2_playbook_on_vars_promptrZv2_playbook_on_play_startZv2_playbook_on_no_hosts_matchedz~/z%s.retryz	to retry, use: --limit @%s
Zv2_playbook_on_statszNo issues encounteredZ
start_at_taskzSNo matching task "%s" found. Note: --start-at-task can only follow static includes.)H�listr�allr
rrrr�display�warning�formatrZdefault_collectionr�loadr r!r&Zload_callbacksZ
send_callbackZ	get_playsZvv�lenr	Z_included_pathZset_basedirZ_basedirrZremove_restrictionZget_varsr�setattr�templater0r%r
Z
extra_varsZ
do_var_prompt�varsZ
post_validaterr$�appendr#�updateZ
_failed_hosts�_get_serialized_batchesZrestrict_to_hosts�runr�resultZRUN_FAILED_BREAK_PLAYZRUN_FAILED_HOSTS�CZRETRY_FILES_ENABLED�set�keys�sortedZRETRY_FILES_SAVE_PATH�os�path�dirname�abspath�splitext�basename�join�_generate_retry_inventoryZ_statsZcleanupZcleanup_all_tmp_filesZ_start_at_done�error)$r'rHZ	entrylist�entryr-�resourceZ
playbook_pathZplaybook_collectionZpb�ir.r/Zall_varsZtemplar�varZvnamer2r3r4r5r6r7r8r9Zpreviously_failedZpreviously_unreachableZ
break_playZbatchesZbatch�eZfailed_hosts_countZretriesZbasedirZ
retry_name�_�filenamer(r(r)rGNs






�"

&�


�
�

��zPlaybookExecutor.runc
Cs�|jj|j|jd�}t|�}|j}t|�dkr4dg}d}g}t|�dkr�t|||�}|dkrl|�|�q�n8g}t|�D] }	t|�dkrx|�|�	d��qx|�|�|d7}|t|�dkr<t|�d}q<|S)zz
        Returns a list of hosts, subdivided into batches based on
        the serial size specified in the play.
        )�orderr���r+)
rZ	get_hosts�hostsr]r@�serialrrD�range�pop)
r'r/Z	all_hostsZ
all_hosts_lenZserial_batch_listZcur_itemZserialized_batchesr`Z
play_hosts�xr(r(r)rFs*

z(PlaybookExecutor._get_serialized_batchesc
Cs�zVttj�|��t|d��(}|D]}|�d|�q"Wd�n1sJ0YWn<ty�}z$t�d|t	|�f�WYd}~dSd}~00dS)z�
        Called when a playbook run fails. It generates an inventory which allows
        re-running on ONLY the failed hosts.  This may duplicate some variable
        information in group_vars/host_vars but that is ok, and expected.
        �wz%s
Nz%Could not create retry file '%s'.
	%sFT)
rrMrNrO�open�write�	Exceptionr<r=r	)r'Z
retry_pathZreplay_hosts�fdrcrZr(r(r)rT@s2z*PlaybookExecutor._generate_retry_inventoryN)�__name__�
__module__�__qualname__�__doc__r*rGrFrTr(r(r(r)r+sE.r))Z
__future__rrr�typeZ
__metaclass__rMZansiblerrIrZ#ansible.executor.task_queue_managerrrZansible.module_utils._textr	Z)ansible.module_utils.parsing.convert_boolr
Zansible.plugins.loaderrrr
Zansible.playbookrZansible.templaterZansible.utils.helpersrZansible.utils.collection_loaderrZ2ansible.utils.collection_loader._collection_finderrrZansible.utils.pathrZansible.utils.ssh_functionsrZansible.utils.displayrr<rr(r(r(r)�<module>s$

Zerion Mini Shell 1.0