HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/lib/python3.9/site-packages/ansible/plugins/strategy/__pycache__/linear.cpython-39.pyc
a

�)g�O�@s�ddlmZmZmZeZdZddlmZ	ddl
mZmZm
Z
ddlmZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lm Z e �Z!Gdd�de�Z"dS)�)�absolute_import�division�print_functiona
    name: linear
    short_description: Executes tasks in a linear fashion
    description:
        - Task execution is in lockstep per host batch as defined by C(serial) (default all).
          Up to the fork limit of hosts will execute each task at the same time and then
          the next series of hosts until the batch is done, before going on to the next task.
    version_added: "2.0"
    notes:
     - This was the default Ansible behaviour before 'strategy plugins' were introduced in 2.0.
    author: Ansible Core Team
)�	constants)�AnsibleError�AnsibleAssertionError�AnsibleParserError)�IteratingStates�FailedStates)�to_text)�Handler)�IncludedFile)�Task)�
action_loader)�StrategyBase)�Templar)�Displaycs0eZdZ�fdd�Zdd�Z�fdd�Z�ZS)�StrategyModulecst�j|i|��d|_dS)NF)�super�__init__�_in_handlers)�self�args�kwargs��	__class__��C/usr/lib/python3.9/site-packages/ansible/plugins/strategy/linear.pyr3szStrategyModule.__init__c
Cs�t�}d|_d|jd<d|_|�|jj�i}|D]*}|j|dd�\}}|dur2||f||<q2|spdd�|D�S|jr�t	t
d	d
�dd�|��D���s�d
|_|jr�tdd�|��D��}nzdd�|��D�}	d}
|
dk�r,z|j
|j}Wn"t�yd|_|
d7}
Yq�0|jd7_|j|	vrАq4q�td��g}|��D]d\}\}}|j�r`||jk�sv|j�s�|j|jk�r�|�|j|�|�||f�n|�||f��q@|j�s�|jtjv�r�|j�d�dk�r�d|_|S)z�
        Returns a list of (host, task) tuples, where the task may
        be a noop task to keep the iterator in lock step across
        all hosts.
        �meta�noop�_raw_paramsT��peekNcSsg|]}|df�qS�Nr)�.0�hrrr�
<listcomp>L�z:StrategyModule._get_next_task_lockstep.<locals>.<listcomp>cSs
|tjkSr#)r	�HANDLERS)Zrsrrr�<lambda>Or'z8StrategyModule._get_next_task_lockstep.<locals>.<lambda>css|]\}}|jVqdSr#)�	run_state)r$�s�_rrr�	<genexpr>Pr'z9StrategyModule._get_next_task_lockstep.<locals>.<genexpr>Fcss$|]\}}|jtjkr|jVqdSr#)r*r	r(�cur_handlers_task�r$r+�trrrr-Us�cSsg|]\}}|j�qSr)�_uuidr/rrrr&Zr'r�zOBUG: There seems to be a mismatch between tasks in PlayIterator and HostStates.�flush_handlers)r�actionrZimplicit�
set_loader�_play�_loader�get_next_task_for_hostr�any�filter�values�min�	all_tasks�cur_task�
IndexErrorr1r�itemsr.Zset_state_for_host�name�append�C�_ACTION_META�get)
r�hosts�iteratorZ	noop_taskZstate_task_per_host�host�state�taskZlowest_cur_handlerZ
task_uuidsZ	_loop_cntr>�
host_tasksrrr�_get_next_task_lockstep9sd

��


��
��z&StrategyModule._get_next_task_lockstepc(s�|jj}d}|�|j�|�rz|jj�sz�zt�d�|�|�}t�d�d}d}|�||�}d}d}	d}
g}|D�]�\}}
|
s�qr|jjr��q4d}d}t	|
t
�s�|
jr�|
j�|�r�|
jj
dus�|
jj
r�|
jj
js�t�d|
�qrt�d�|jj|j||
|j|jd�}|j||jd	�t|j|d
�}t�d�|�|
j�}ztj|d|
jd�}Wnt�yjd}Yn0|tjv�r�|�|�|
|||��|
j �d
d�dv�r�d}|
j!�s�|�r�|
j"�s�d}
�n8|j#�r�|	�r�|�$|
��r�d}	n
d}�q4|�|
j%��p|�ot&|dd�}|
j!�s|�r(|
j"�s(d}
|�s�t�d�|
j'}t�d�z(t(|j|
j'dd�dd�|
_'t�d�Wnt)�y�t�d�Yn0t�d�t	|
t
��r�|j�*d|
�n|jj*d|
dd�||
_'d}t�d�d|j+|�,�<|�-||
||�~|�r�q4|�|j.|t/dt0t1|jj2�d��d��qr|�r>Wqt�d�|j3d k�rd|�|�4|��|�5|�t6j7|||j|jd!�}t1|�d k�rt�d"�t�d#�t8d$d%�|D��}t�d&�g}t9�}|D�]�}t�d'|j:�d}�z|j;�r|�<|�}|j=|j|j|jd(�\}}nt	|j>t
�}|j?|||d)�}d*d+�|jj@D�|_@t�d,�|D]�}|�r�|jAD]}
|jBdd�|
_C�qj|}nJ|jj|j|�D�|j|jd-�}t�d.�|�E|�}t�d/�|�|�F��|D] }||jBv�r�||�G|��q֐qZt�d0�Wn�tH�y�YnrtI�y�}zX|j;�rHtjJt(|�dd1�|jKD]} d| jLd2<|�M| jN��qNWYd}~�q�WYd}~n
d}~00�q�|D]}d|jjO|j'<|�P|��q�t�d3�|D]}|�Q|||��q�||jR|jS|jS�<t�d4�t�d5�t�d6�t�d7�g}!g}"|D]V}#|#�T��sB|#j>jtjv�r`|�T|#jN��r`|!�G|#jNj'�n|#�U��r$|"�G|#jNj'��q$|
�rt1|!�d k�s�t1|"�d k�rtVtWjXtWjYg�}$|D]h}|jZ|dd8�\}%}&|�[|%�}%|%j\|$v�s�|%j\tWjXk�r�|%j]t^jX@d k�r�d|jjO|j'<||jj_O}�q�t�d9�t�d:�|jj`du�r�t1|�d k�r�|jj`d;}'t1|jjO�|ja|'k�r�|D]*}|j'|!v�rtd|jjO|j'<|�P|��qt|j�*d<�||jj_O}t�d=t1|jjO�|ja|'f�t�d>�t�d?�||jjk�r*t1|jjO�t1|�k�r*t�d@�|j�*d<�|WSt�dA�Wqtbtcf�yv}z"t�dB|�|jjdWYd}~Sd}~00qtetf|��g|||�S)Cz�
        The linear strategy is simple - get the next task and queue
        it for all hosts, then wait for the queue to drain before
        moving on to the next task
        Tz)getting the remaining hosts for this loopz.done getting the remaining hosts for this loopFNz)'%s' skipped because role has already runzgetting variables)�playrHrJ�_hosts�
_hosts_all)rM)�loaderZ	variableszdone getting variables)Z
class_onlyZcollection_listr )rZreset_connectionZend_hostZ
role_completer3ZBYPASS_HOST_LOOPzOsending task start callback, copying the task so we can template it temporarilyz#done copying, going to template now)Zfail_on_undefined�empty)Z	nonstringzdone templatingz!templating failed for some reasonzhere goes the callback...Z!v2_playbook_on_handler_task_startZv2_playbook_on_task_start)Zis_conditionalzsending task start callbackr2g�������?)Z
max_passesz>done queuing things up, now waiting for results queue to drainr)rGrP�variable_managerz!we have included files to processzgenerating all_blocks datacss|]}|gfVqdSr#r)r$rHrrrr-r'z%StrategyModule.run.<locals>.<genexpr>zdone generating all_blocks datazprocessing included file: %s)rMrRrP)rG�
is_handlercSsg|]}|jD]}|�qqSr)�block)r$�br%rrrr&'r'z&StrategyModule.run.<locals>.<listcomp>z2iterating over new_blocks loaded from include file)rMrJrNrOzfiltering new block on tagsz done filtering new block on tagsz7done iterating over new_blocks loaded from include file)Z	wrap_textZfailedz7extending task lists for all hosts with included blockszdone extending task listszdone processing included fileszresults queue emptyzchecking for any_errors_fatalr!z"done checking for any_errors_fatalz checking for max_fail_percentagegY@Z!v2_playbook_on_no_hosts_remainingz$(%s failed / %s total )> %s max failz%done checking for max_fail_percentagezIchecking to see if all hosts have failed and the running result is not okz!^ not ok, so returning result nowz-done checking to see if all hosts have failedz%got IOError/EOFError in task loop: %s)hZ_tqmZRUN_OKZ_set_hosts_cacher6Z_terminated�display�debugZget_hosts_leftrL�
isinstancerZ_roleZhas_runZ	_metadataZallow_duplicatesZ_variable_managerZget_varsZ_hosts_cacheZ_hosts_cache_allZadd_tqm_variablesrr7�templater4rrE�collections�KeyErrorrCrD�extendZ
_execute_metar�any_errors_fatal�
ignore_errorsZ_stepZ
_take_step�run_once�getattrrAr�	ExceptionZ
send_callbackZ_blocked_hostsZget_nameZ_queue_taskZ_process_pending_results�max�int�lenZ_workersZ_pending_resultsZ_wait_on_pending_resultsZupdate_active_connectionsr
Zprocess_include_results�dict�setZ	_filenameZ_is_roleZ_copy_included_fileZget_block_listZ_taskZ_load_included_file�handlersrTrNZnotified_hostsZget_first_parent_includeZfilter_tagged_tasksZ	get_tasksrBrr�errorZ_resultsZ_result�addZ_hostZ
_failed_hostsZmark_host_failedZ	add_tasksr=r>Z	is_failedZis_unreachable�	frozensetr	ZRESCUEZALWAYSr8Zget_active_stater*Z
fail_stater
ZRUN_FAILED_BREAK_PLAYZmax_fail_percentageZ
batch_size�IOError�EOFErrorZRUN_UNKNOWN_ERRORrr�run)(rrGZplay_context�resultZ
work_to_doZ
hosts_leftZ
callback_sentrKZ	skip_restZchoose_stepr]�resultsrHrJr_Z	task_varsZtemplarZtask_actionr4Z
saved_nameZincluded_filesZ
all_blocksZincluded_tasksZfailed_includes_hostsZ
included_filerSZnew_irZ
new_blocksZhandler_blocksZ	new_blockZfinal_block�e�rZfailed_hostsZunreachable_hosts�resZdont_fail_statesr+r,Z
percentagerrrrmsz



�

 



,

�




�

�




(




(
"

��



$
 zStrategyModule.run)�__name__�
__module__�__qualname__rrLrm�
__classcell__rrrrr1sFrN)#Z
__future__rrr�typeZ
__metaclass__Z
DOCUMENTATIONZansiblerrCZansible.errorsrrrZansible.executor.play_iteratorr	r
Zansible.module_utils._textrZansible.playbook.handlerrZansible.playbook.included_filer
Zansible.playbook.taskrZansible.plugins.loaderrZansible.plugins.strategyrZansible.templaterZansible.utils.displayrrVrrrrr�<module>s