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: //lib/python3.9/site-packages/ansible/plugins/strategy/__pycache__/free.cpython-39.pyc
a

�)gX>�@s�ddlmZmZmZeZdZddlZddlm	Z
ddlmZm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZe�ZGd
d�de�ZdS)�)�absolute_import�division�print_functiona�
    name: free
    short_description: Executes tasks without waiting for all hosts
    description:
        - Task execution is as fast as possible per batch as defined by C(serial) (default all).
          Ansible will not wait for other hosts to finish the current task before queuing more tasks for other hosts.
          All hosts are still attempted for the current task, but it prevents blocking new tasks for hosts that have already finished.
        - With the free strategy, unlike the default linear strategy, a host that is slow or stuck on a specific task
          won't hold up the rest of the hosts and tasks.
    version_added: "2.0"
    author: Ansible Core Team
N)�	constants)�AnsibleError�AnsibleParserError)�Handler)�IncludedFile)�
action_loader)�StrategyBase)�Templar)�to_text)�Displaycs,eZdZdZ�fdd�Z�fdd�Z�ZS)�StrategyModuleFcstt|��|�d|_dS)NF)�superr�__init__�_host_pinned)�selfZtqm��	__class__��A/usr/lib/python3.9/site-packages/ansible/plugins/strategy/free.pyr6szStrategyModule.__init__c"sd}|jj}t|j�}|�|j�|jjdur8t�d�d}|�r�|jj	�s�|�
|�}t|�dkrv|j�d�d}�q�d}|}g}	||}
t�d|
�|
�
�}|j|
dd�\}}
tjd	||d
�tjd|
|d
�|
s�|j�|d��r|jj�|d��stjd|d
�d}|jj�|d��sB|
�rB|j�|d��s4tjd
|d
�|jj|j|
|
|j|jd�}|j||jd�t|j|d�}tjd|d
�zt|�|
j��}Wn6t�y�}ztd|
j|d��WYd}~n
d}~00|dk�r@d}|jD].}|�r�|���r�|j j!|
j!k�r�|d7}�q�t�d|
�
�|f�||k�r@�q�d|j|<|�"|
j#|�zt$j|
j%d|
j&d�}Wnt'�y�d}Yn0z,t(|j|
j#dd�dd�|
_#tjd|d
�Wn"t�y�tjd|d
�Yn0|�|
j)��p�|�o�t*|dd�}|�r4|�r*t*|dd��r*td|
j%|
jd��n
t�d�t+|
t,��s�|
j-�r�|
j-�.|
��r�|
j-j/du�sz|
j-j/�r�|
j-j/j0�s�tjd |
|d
�|j|=q�|
j%t1j2v�r�|j3|
|||
d!�d|j|<np|j4�r�|�5|
|��rB|
j6�r�t�d"�t+|
t,��r|j�d#|
�n|jjd$|
dd%�|�7|
|
||�|d8}~nt�d&|�|j8�rb|dk�rb|�rb|}�q�|d7}|t|�dk�r�d}||kr��q�q�|�9|�}|	�:|�|t|�7}|�;|�t<j=|	||j|jd'�}t|�dk�r�t>d(d)�|D��}t?�}|D�]�}t�d*|�d}zb|j@�r@|�A|�}|jB|j|j|jd+�\}}nt+|j t,�}|jC|||d,�}d-d.�|jjDD�|_DWn�tE�y��Ynrt�y�}zX|j@�r�tjFt(|�dd/�|jGD]}d|jHd0<|�I|jJ��q�WYd}~�q�WYd}~n
d}~00|D]~} |�r,| jKD]}
|jLdd�|
_M�q| }!n(|jj|j| �N�|j|jd1�}| �O|�}!|D] }
|
|jLv�rX||
�P|!��qX�q�t�d2|��q�|D]}
d|jjQ|
j#<|�R|
��q�t�d3t|��|D]}
|�S|
||
��q�t�d4�tT�Ut1jV�q<|�W|�}tXtY|��Z|||�S)5am
        The "free" strategy is a bit more complex, in that it allows tasks to
        be sent to hosts as quickly as they can be processed. This means that
        some hosts may finish very quickly if run tasks result in little or no
        work being done versus other systems.

        The algorithm used here also tries to be more "fair" when iterating
        through hosts by remembering the last host in the list to be given a task
        and starting the search from there as opposed to the top of the hosts
        list again, which would end up favoring hosts near the beginning of the
        list.
        rNzsUsing max_fail_percentage with the free strategy is not supported, as tasks are executed independently on each hostTZ!v2_playbook_on_no_hosts_remainingFznext free host: %s)�peekzfree host state: %s)�hostzfree host task: %szthis host has work to dozgetting variables)�playr�task�_hosts�
_hosts_all)r)�loaderZ	variableszdone getting variablesz3Failed to convert the throttle value to an integer.)�objZorig_exc�ztask: %s, same_tasks: %d)Z
class_onlyZcollection_list)Zfail_on_undefined�empty)Z	nonstringzdone templatingz!templating failed for some reasonZBYPASS_HOST_LOOPz�The '%s' module bypasses the host loop, which is currently not supported in the free strategy and would instead execute for every host in the inventory list.)rz�Using run_once with the free strategy is not currently supported. This task will still be executed for every host in the inventory list.z)'%s' skipped because role has already run)Ztarget_hostzpUsing any_errors_fatal with the free strategy is not supported, as tasks are executed independently on each hostZ!v2_playbook_on_handler_task_startZv2_playbook_on_task_start)Zis_conditionalz%s is blocked, skipping for now)�iteratorr�variable_managercss|]}|gfVqdS)Nr)�.0rrrr�	<genexpr>��z%StrategyModule.run.<locals>.<genexpr>zcollecting new blocks for %s)rr#r)r"�
is_handlercSsg|]}|jD]}|�qqSr)�block)r$�b�hrrr�
<listcomp>r&z&StrategyModule.run.<locals>.<listcomp>)Z	wrap_textZfailed)rrrrz!done collecting new blocks for %sz@adding all collected blocks from %d included file(s) to iteratorz(done adding collected blocks to iterator)[Z_tqmZRUN_OK�lenZ_workersZ_set_hosts_cacheZ_playZmax_fail_percentage�displayZwarningZ_terminatedZget_hosts_leftZ
send_callback�debugZget_nameZget_next_task_for_hostZ_blocked_hosts�getZ_unreachable_hostsZ_variable_managerZget_varsZ_hosts_cacheZ_hosts_cache_allZadd_tqm_variablesrZ_loader�int�template�throttle�	ExceptionrZ_ds�is_aliveZ_taskZ_uuidZset_state_for_host�namer
�action�collections�KeyErrorr
�run_once�getattr�
isinstancerZ_roleZhas_runZ	_metadataZallow_duplicates�CZ_ACTION_METAZ
_execute_metaZ_stepZ
_take_stepZany_errors_fatalZ_queue_taskrZ_process_pending_results�extendZupdate_active_connectionsr	Zprocess_include_results�dict�setZ_is_roleZ_copy_included_fileZget_block_listZ_load_included_file�handlersr�errorZ_resultsZ_result�addZ_hostr(rZnotified_hostsZget_first_parent_includeZfilter_tagged_tasks�appendZ
_failed_hostsZmark_host_failedZ	add_tasks�time�sleepZDEFAULT_INTERNAL_POLL_INTERVALZ_wait_on_pending_resultsrr�run)"rr"Zplay_contextZ	last_host�resultZworkers_freeZ
work_to_doZ
hosts_leftZ
starting_hostZhost_resultsrZ	host_name�staterZ	task_varsZtemplarr2�eZ
same_tasksZworkerr6r9�resultsZincluded_filesZ
all_blocksZfailed_includes_hostsZ
included_filer'Znew_irZ
new_blocksZhandler_blocks�rZ	new_blockZfinal_blockrrrrF:s6


&�&

 


 ��
"$



�

�

$
�


zStrategyModule.run)�__name__�
__module__�__qualname__ZALLOW_BASE_THROTTLINGrrF�
__classcell__rrrrr1sr)Z
__future__rrr�typeZ
__metaclass__Z
DOCUMENTATIONrDZansiblerr<Zansible.errorsrrZansible.playbook.handlerrZansible.playbook.included_filer	Zansible.plugins.loaderr
Zansible.plugins.strategyrZansible.templaterZansible.module_utils._textr
Zansible.utils.displayrr-rrrrr�<module>s