
    Vh<                        d dl mZ d dlZd dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZ  e       ZddZdd	Zdd
Zy)    )annotationsN)	constants)AnsibleParserErrorAnsibleUndefinedVariableAnsibleAssertionError)	to_native)ModuleArgsParser)Displayc                    ddl m} t        | t        t	        d      f      st        | dt	        |             g }	| rt        t        t        |                   }
|
D ]  }| |   }g }|M|j                  |      s<|j                  |       |dz  }t        |
d       	 | |   }||j                  |      s<||fD ]-  }|s|	j                  |j                  ||||||||             /  |	S # t        $ r d}Y Yw xY w)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.
    r   BlockNz! should be a list or None but is    playparent_blockroletask_includeuse_handlersvariable_managerloader)ansible.playbook.blockr   
isinstancelisttyper   iterrangelenis_blockappendnext
IndexErrorload)dsr   r   r   r   r   r   r   r   
block_listcountiblock_dsimplicit_blocksbs                  H/home/dcms/DCMS/lib/python3.12/site-packages/ansible/playbook/helpers.pyload_list_of_blocksr+      s,    -b4d,-#rSWXZS[$\]]J	U3r7^$ 	A!uH !O&u~~h/G&&x0QUD!$!!uH &u~~h/G &x0 %%

!%)5!%)5)5-=#) # 	#	@ ' " $#H$s   C//C=<C=c                   ddl m} ddlm}	 ddlm}
 ddlm} ddlm	} ddl
m} ddlm} t        | t              st!        d	| d
t#        |             g }| D ]  }t        |t$              st!        d	| dt#        |             d|v r:|rt'        d|      |j)                  ||||||||      }|j+                  |       lt-        |      }	 |j/                  d      \  }}}|t4        j6                  v rp|r|}n|}|j)                  |||d||      }|j9                  ||      } |||      }|t4        j:                  v r|j<                  t'        d|      d|_        |}d}d}d}|rd}|kt        ||      s|j@                  }	 tB        jD                  jG                  |jI                  |jJ                  jM                  d                  }||}n?tB        jD                  jQ                  |      s tB        jD                  jS                  ||      }|jI                  |jJ                  d         }|jT                  rItB        jD                  jS                  |jT                  jV                  ||      } |jY                  | ||      }!n!|jY                  |j[                         ||      }!tB        jD                  j]                  |!      rd}n|j@                  }|k|sd	 |jI                  |jJ                  d         }|jT                  r(|jY                  |jT                  jV                  ||      }!n|j_                  |      }!|ja                  !      }"|"stb        je                  d|!z         t        |"t              st'        d |"      tb        jg                  d!|!z         |ji                  d"      }#||#_         tk        |"|d|#||||#      }$|#jl                  dd }%|$D ]4  }&t        to        |&jl                        jq                  |%            |&_6        6 |r$|$D ]  }&|js                  |&jt                          |js                  |$       |j+                  |       |t4        jv                  v r|rt'        d$| d%|      |j)                  |||d||      }'|t4        jx                  v r|'j<                  t'        d&|      d|'_        |j9                  ||'      } |||      }|'j{                  |'       |jI                  |'j|                        |'_>        |'j                  ||(      \  }(})|js                  |(       |j+                  |'       
|r\|	j)                  ||||||      }|j                  t4        j                  v r|jJ                  jM                  d      d)k(  rit'        d*      |
j)                  ||||||      }|j                  t4        j                  v r+|jJ                  jM                  d      d)k(  r|t'        d+      |j+                  |        |S # t&        $ r)}|j0                  r t'        t3        |      ||      d}~ww xY w# tN        $ r=}|j>                  s+t'        d|jJ                  jM                  d      z  |d|       d}~ww xY w# tN        $ r$}t'        d|jJ                  d   z  |d|      d}~ww xY w),zw
    Given a list of task datastructures (parsed from YAML),
    return a list of Task() or TaskInclude() objects.
    r   r   )Handler)Task)TaskInclude)IncludeRole)HandlerTaskInclude)TemplarzThe ds () should be a list but was a z) should be a dict but was a blockz,Using a block as a handler is not supported.)objr   T)skip_action_validation)r5   orig_excN)r4   r   r   r   r   )r   task)r   	variableszZYou cannot use loops on 'import_tasks' statements. You should use 'include_tasks' instead.Ftaskshandlers_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)r5   suppress_extended_errorr7   a'  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 taskszstatically imported: %s)exclude_parent)r   r   r   r   r   r   r   zUsing 'z ' as a handler is not supported.zXYou cannot use loops on 'import_role' statements. You should use 'include_role' instead.)templar)r   r   end_rolez(Cannot execute 'end_role' from a handlerz0Cannot execute 'end_role' from outside of a role)Br   r   ansible.playbook.handlerr-   ansible.playbook.taskr.   ansible.playbook.task_includer/   ansible.playbook.role_includer0   %ansible.playbook.handler_task_includer1   ansible.templater2   r   r   r   r   dictr   r"   r   r	   parser5   r   C _ACTION_ALL_INCLUDE_IMPORT_TASKSget_vars_ACTION_IMPORT_TASKSloopstatically_loaded_parentospathdirnametemplateargsgetr   isabsjoin_role
_role_pathpath_dwim_relativeget_basedirexists	path_dwimload_from_filedisplaywarningvvcopyr+   tagssetunionextendr4   '_ACTION_ALL_PROPER_INCLUDE_IMPORT_ROLES_ACTION_IMPORT_ROLEpost_validate
_role_nameget_block_listaction_ACTION_META)*r#   r   r4   r   r   r   r   r   r   r-   r.   r/   r0   r1   r2   	task_listtask_dstargs_parserrl   rT   delegate_toeinclude_classall_varsr?   parent_includecumulative_pathfoundsubdirparent_include_dirinclude_targetnew_basedirinclude_filedatati_copyincluded_blocksrc   r)   irblocksdummys*                                             r*   load_list_of_tasksr   R   s    -0*99H(b$#SUW[\^W_$`aaI J$'4('WY[_`b[c(deeg()W]dee

"))!1  	A Q*73KP.9.?.?W[.?.\+{ ;;;$6M$/M!&&!%%5! '  ,44$Q4G!8D Q333vv)0  2N  T[  \  \ +/A' &+N&*O!E$F#!+(4).+F-;-C-CN$"13AQAQR`ReReRiRijwRxAy1z. +2.@O!#!?.0ggll;M._O)0)9)9!&&:O)P77*,'',,qww7I7I6Sb*cK+1+D+D[RXZh+iL+1+D+DVEWEWEY[jlz+{L77>>,7$(E!-;-C-CNA )4D !
,-4-=-=aff]>S-TN 77+1+D+DQWWEWEWY_ao+pL+1+;+;N+KL!00>D(VYe(ef 'd301cimnn JJ8<GHffDf9G&+GO&9!%)%,!%1%)9	'O #<<?D - ?!%c!&&k&7&7&=!>? $!0 6A%,,QWW56 "((9$$Q'1DDD,wvh>^-_elmm %%!%%5! &  Q222ww*0  2L  RY  Z  Z ,0B(  088d8LH%VxHG$$W$5$+$4$4R]]$CBM %'$5$5GW`f$5$gMFE$$V, $$R(WES_  sC  LR  SAxx1>>1affjj6OS]6]01[\\		'TP\o  IO	  PAxx1>>1affjj6OS]6]bfbn01cdd  #UJ$X m & P 55(17QOOPd  8 
"#1#C#C&8%BDRDWDWD[D[\iDj%k )0<@-.'" !" "
">  8 ,"4!C FGVVMEZ![ %,8<)*#, ,,sI   X5AY*%Z35	Y'>$Y""Y'*	Z038Z++Z03	[ <[[ c           	         ddl m} t        | t              st	        d| dt        |             g }| D ]*  }|j                  ||||||      }	|j                  |	       , |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 (r3   )r   current_role_pathr   r   collection_list)ansible.playbook.role.includer   r   r   r   r   r"   r   )
r#   r   r   r   r   collection_search_listr   rolesrole_defr&   s
             r*   load_list_of_rolesr   4  st     :b$#rSWXZS[$\]]E XDDUhx$*<R  TQ
 L    )NNNFNN)NNNN)
__future__r   rP   ansibler   rI   ansible.errorsr   r   r   +ansible.module_utils.common.text.convertersr   ansible.parsing.mod_argsr	   ansible.utils.displayr
   r_   r+   r   r    r   r*   <module>r      s8   $ # 	 " ^ ^ A 5 )
)0f_Dr   