o nnh8;@sddlmZddlZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZeZdd d Zdd d Zdd dZdS)) annotationsN) constants)AnsibleParserErrorAnsibleUndefinedVariableAnsibleAssertionError) to_native)ModuleArgsParser)DisplayFcCsddlm}t|ttdfstd|t|fg} |r{ttt|} | D]S} || } g} | dura| | sa| | | d7} t | dz|| } Wn t yWd} Ynw| dura| | r8| | fD]}|ry| |j ||||||||dqeq'| S)z Given a list of mixed task/block data (parsed from YAML), return a list of Block() objects, where implicit blocks are created for each bare Task. rBlockNz%%s should be a list or None but is %splay parent_blockrole task_include use_handlersvariable_managerloader)ansible.playbook.blockr isinstancelisttyperiterrangelenis_blockappendnext IndexErrorload)dsrrrrrrrr block_listcountiblock_dsimplicit_blocksbr(C/usr/local/lib/python3.10/dist-packages/ansible/playbook/helpers.pyload_list_of_blockssH      r*c* Cs&ddlm}ddlm} ddlm} ddlm} ddlm } ddl m } ddl m }t|ts9td |t|fg}|D]R}t|tsOtd |t|fd |vrn|r[td |d |j||||||||d}||q=t|}z |jdd\}}}Wnty}z |jrtt|||dd}~ww|tjvr|r| }n| }|j|||d||d}|j||d}|||d}|tjvr |jdurtd|d d|_|}d}d}d}|rd}|durht|| s|j }qzt!j"#|$|j%&d}Wn t'y}z|jstd|j%&d|d|dd}~ww|dur"|}nt!j"(|s0t!j")||}|$|j%d}|j*rNt!j")|j*j+||} |,| ||}!n |,|-||}!t!j".|!rad}n|j }|dus|sz |$|j%d}Wnt'y}z td|j%d|d|dd}~ww|j*r|,|j*j+||}!n|/|}!|0|!}"|"st12d|!q=t|"tstd|"d t13d |!|j4dd!}#||#_ t5|"|d|#||||d"}$|#j6dd}%|$D]}&tt7|&j68|%|&_6q|r|$D] }&|9|&j:qq=|9|$q=||q=|tj;vrq|r"td#|d$|d | j|||d||d}'|tj|'_>|'j?||d'\}(})|9|(q=||'q=|r| j||||||d}n | j||||||d}||q=|S)(zw Given a list of task datastructures (parsed from YAML), return a list of Task() or TaskInclude() objects. rr )Handler)Task) TaskInclude) IncludeRole)HandlerTaskInclude)Templarz)The ds (%s) should be a list but was a %sz)The ds (%s) should be a dict but was a %sblockz,Using a block as a handler is not supported.)objr T)skip_action_validation)r2orig_excN)r1rrrr)rtask)r variableszZYou cannot use loops on 'import_tasks' statements. You should use 'include_tasks' instead.Ftaskshandlers _raw_paramszError when evaluating variable in dynamic parent include path: %s. When using static imports, the parent dynamic include cannot utilize host facts or variables from inventory)r2suppress_extended_errorr4a'Error when evaluating variable in import path: %s. When using static imports, ensure that any variables used in their names are defined in vars/vars_files or extra-vars passed in from the command line. Static imports cannot use variables from facts or inventory sources like group or host vars.z,file %s is empty and had no tasks to includez0included task files must contain a list of taskszstatically imported: %s)exclude_parent)rrrrrrrzUsing 'z ' as a handler is not supported.zXYou cannot use loops on 'import_role' statements. You should use 'include_role' instead.)templar)rr)@rr ansible.playbook.handlerr+ansible.playbook.taskr,ansible.playbook.task_includer-ansible.playbook.role_includer.%ansible.playbook.handler_task_includer/ansible.templater0rrrrdictrr rrparser2rC _ACTION_ALL_INCLUDE_IMPORT_TASKSget_vars_ACTION_IMPORT_TASKSloopstatically_loaded_parentospathdirnametemplateargsgetrisabsjoin_role _role_pathpath_dwim_relative get_basedirexists path_dwimload_from_filedisplaywarningvvcopyr*tagssetunionextendr1'_ACTION_ALL_PROPER_INCLUDE_IMPORT_ROLES_ACTION_IMPORT_ROLE post_validate _role_nameget_block_list)*r!rr1rrrrrr r+r,r-r.r/r0 task_listtask_dst args_parseractionrP delegate_toe include_classall_varsr<parent_includecumulative_pathfoundsubdirparent_include_dirinclude_target new_basedir include_filedatati_copyincluded_blocksr_r'irblocksdummyr(r(r)load_list_of_tasksRsJ                     "                 rc Cs\ddlm}t|tstd|t|fg}|D]}|j||||||d} || q|S)a Loads and returns a list of RoleInclude objects from the ds list of role definitions :param ds: list of roles to load :param play: calling Play object :param current_role_path: path of the owning role, if any :param variable_manager: varmgr to use for templating :param loader: loader to use for DS parsing/services :param collection_search_list: list of collections to search for unqualified role names :return: r) RoleIncludez%ds (%s) should be a list but was a %s)rcurrent_role_pathrrcollection_list)ansible.playbook.role.includerrrrrr r) r!rrrrcollection_search_listrrolesrole_defr$r(r(r)load_list_of_roles0s   r)NNNFNN)NNNN) __future__rrLansiblerrEansible.errorsrrr+ansible.module_utils.common.text.convertersransible.parsing.mod_argsransible.utils.displayr r[r*rrr(r(r(r)s       3_