a ì)gã:ã@sðddlmZmZmZeZddlZddlmZ ddlm Z ddl m Z m Z ddlmZddlmZddlmZmZmZdd lmZdd lmZdd lmZdd 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] } | jdur0|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$vr†|jrP|j d|||||||||¡ t %|||||||||¡ | j&|<n || j&|<q†|jj| d } t|j| d} |  '| ¡t(j)dr”q|jdur²|d  *| ¡n`|jj+ ,|j+¡t|jj-ƒ}t|jj+ƒ}d}| .| ¡}t|ƒdkr|j d| ¡|j d¡|D]ð}|j /|¡z|jj0| d }Wn<t1yr}z"|j2}WYd}~qWYd}~n d}~00||jj3@dkr’|jj4}d}t|jj-ƒt|jj+ƒ||}t|ƒ|krÊd}q|t|jj-ƒ|7}|t|jj+ƒ|7}|j+ ,|jj+¡q|rq| d} q|r.| *|¡|jdurt5j6rðt7|jj- 8¡ƒ}| ,|jj+ 8¡¡t9|ƒ}t|ƒdkrð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¡|dkrFqqF|rF|W|jdur2|j D¡|jrD|j E¡SW|jdur^|j D¡|jrœ|j E¡n*|jdurˆ|j D¡|jrš|j E¡0t(j)dr¶t d"¡|St(j)d#rà|jjFsà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 r rrrÚdisplayÚwarningÚformatrZdefault_collectionrÚloadr r!r&Zload_callbacksZ send_callbackZ get_playsZvvÚlenr Z_included_pathZ set_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|ƒdkrs$