관리-도구
편집 파일: helpers.cpython-39.opt-1.pyc
a �)ghA � @ s� d dl mZmZmZ eZd dlZd dlmZ d dl mZmZm Z mZ d dlmZ d dlmZ d dlmZ d dlmZ e� Zdd d�Zddd �Zddd�ZdS )� )�absolute_import�division�print_functionN)� constants)�AnsibleParserError�AnsibleUndefinedVariable�AnsibleFileNotFound�AnsibleAssertionError)� to_native)�string_types)�ModuleArgsParser)�DisplayFc C s� ddl m} t| ttd�f�s2td| t| �f ��g } | r�ttt| ���} | D ]�}| | }g } |dur�|� |�s�| � |� |d7 }t| d� z| | }W q^ ty� d}Y q^0 q^| |fD ](}|r�| � |j ||||||||d�� q�qN| 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. r ��BlockNz%%s should be a list or None but is %s� ��play�parent_block�role�task_include�use_handlers�variable_manager�loader)�ansible.playbook.blockr � isinstance�list�typer �iter�range�lenZis_block�append�next� IndexError�load)�dsr r r r r r r r Z block_list�count�iZblock_dsZimplicit_blocks�b� r( �</usr/lib/python3.9/site-packages/ansible/playbook/helpers.py�load_list_of_blocks! s@ �� r* c - C s ddl m} ddlm} ddlm} ddlm} ddlm } ddl m} ddlm } dd lm} t| t�s~td | t| �f ��g }| D �]|}t|t�s�td| t| �f ��d|v r�|r�td |d��|j||||||||d�}|�|� q�t|�}z|jdd�\}}}W nB t�yH } z(|j�r"� tt|�||d��W Y d}~n d}~0 0 |tjv �r�|�rb| }n|}|j|||d||d�}|j||d�}|||d�}|tjv �r�d}nP|tj v �r�d}n>|d�}t!�"d| d� |�#|j$d � �o�|�%� �o�|j& }|�r�|j&du�r0|tj v �r$td|d��ntd|d��d|_'|}d}d}d} |�rPd} |du�rxt||��sp|j(}�qPzt)j*�+|�,|j$�-d���}!W nL t.�y� } z2|j'�s�td |j$�-d� |d|d!��� W Y d}~n d}~0 0 |du �r�|!}nt)j*�/|��st)j*�0|!|�}|�,|j$d �}"|j1�rDt)j*�0|j1j2| |�}#|�3|#| |"�}$n|�3|�4� ||"�}$t)j*�5|$��rnd}�qxn|j(}�qP|�s�z|�,|j$d �}"W n@ t.�y� } z&td"|j$d |d|d!��W Y d}~n d}~0 0 |j1�r�|�3|j1j2| |"�}$n |�6|"�}$|�7|$�}%|%�st!�8d#|$ � q�nt|%t��s4td$|%d��t!�9d%|$ � |j:dd&�}&||&_(t;|%|d|&||||d'�}'|&j<dd� }(|'D ]})tt=|)j<��>|(��|)_<�q~|�r�|'D ]})|�?|)j@� �q�n |�?|'� nd|_A|�|� q�|tjBv �r�|�r td(|� d)�|d��|j|||d||d�}*d}|tjCv �r*d}|�r�|*j&du�rb|tjCv �rVtd*|d��ntd+|d��d|*_'|j||*d�}|||d�}|*jD|d,� |�,|*jE�|*_E|*jF||d-�\}+},|�?|+� n |�|*� 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. r r )�Handler)�Task)�TaskInclude)�IncludeRole)�HandlerTaskInclude)�Templar)�get_versioned_doclinkz)The ds (%s) should be a list but was a %sz)The ds (%s) should be a dict but was a %s�blockz,Using a block as a handler is not supported.)�objr T)Zskip_action_validation)r3 �orig_excN)r2 r r r r )r Ztask)r Z variablesFz(user_guide/playbooks_reuse_includes.htmlzS"include" is deprecated, use include_tasks/import_tasks instead. See %s for detailsz2.16Z_raw_paramszZYou cannot use loops on 'import_tasks' statements. You should use 'include_tasks' instead.z1You cannot use 'static' on an include with a loopZtasks�handlersz�Error 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)r3 Zsuppress_extended_errorr4 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 taskszstatically imported: %s)Zexclude_parent)r r r r r r r zUsing 'z ' as a handler is not supported.zXYou cannot use loops on 'import_role' statements. You should use 'include_role' instead.z6You cannot use 'static' on an include_role with a loop)�templar)r r )Gr r Zansible.playbook.handlerr+ Zansible.playbook.taskr, Zansible.playbook.task_includer- Zansible.playbook.role_includer. Z%ansible.playbook.handler_task_includer/ Zansible.templater0 Zansible.utils.plugin_docsr1 r r r r �dictr r# r r �parser3 r �CZ _ACTION_ALL_INCLUDE_IMPORT_TASKSZget_varsZ_ACTION_INCLUDE_TASKSZ_ACTION_IMPORT_TASKS�displayZ deprecatedZis_template�argsZall_parents_staticZloopZstatically_loadedZ_parent�os�path�dirname�template�getr �isabs�joinZ_roleZ _role_pathZpath_dwim_relativeZget_basedir�existsZ path_dwimZload_from_fileZwarningZvv�copyr* �tags�set�union�extendr2 � is_staticZ'_ACTION_ALL_PROPER_INCLUDE_IMPORT_ROLESZ_ACTION_IMPORT_ROLEZ post_validateZ _role_nameZget_block_list)-r$ r r2 r r r r r r r+ r, r- r. r/ r0 r1 Z task_listZtask_ds�tZargs_parser�actionr; Zdelegate_to�eZ include_classZall_varsr6 rI Zinclude_linkZparent_includeZcumulative_path�foundZsubdirZparent_include_dirZinclude_targetZnew_basedirZinclude_file�dataZti_copyZincluded_blocksrE r'