관리-도구
편집 파일: task.cpython-39.pyc
a �����)g6S����������������������@���s*��d�dl�mZmZmZ�eZd�dlmZ�d�dl m Z mZmZm Z �d�dlmZ�d�dlmZ�d�dlmZ�d�dlmZmZ�d�dlmZ�d�d lmZmZ�d�d lmZ�d�dlmZ�d�dl m!Z!�d�d l"m#Z#�d�dl$m%Z%�d�dl&m'Z'�d�dl(m)Z)�d�dl*m+Z+�d�dl,m-Z-�d�dl.m/Z/�dgZ0e-��Z1G�dd��dee#e)e!�Z2dS�)�����)�absolute_import�division�print_function)� constants)�AnsibleError�AnsibleParserError�AnsibleUndefinedVariable�AnsibleAssertionError)� to_native)�string_types)�ModuleArgsParser)�AnsibleBaseYAMLObject�AnsibleMapping)� lookup_loader)�FieldAttribute�NonInheritableFieldAttribute)�Base)�Block)�CollectionSearch)�Conditional)�LoopControl)�Role)�Taggable)�AnsibleCollectionConfig)�Display)�Sentinel�Taskc�����������������������s���e�Zd�ZdZeded�Zedd�Zedddd �Zed e d�Z eddd�Zedd�Z edd�Zed e d�Ze��Zed eed�Zed d�Zedejd�Zeddd�Zeddd�Zed e d�Zeddd�ZdK��fdd� ZdLdd�Zdd��ZedMdd��Zdd��Z dd��Z!��fd d!�Z"d"d#��Z#��fd$d%�Z$d&d'��Z%d(d)��Z&��fd*d+�Z'd,d-��Z(d.d/��Z)d0d1��Z*d2d3��Z+d4d5��Z,d6d7��Z-d8d9��Z.d:d;��Z/dN��fd=d>� Z0��fd?d@�Z1��fdAdB�Z2dCdD��Z3dOdEdF�Z4dGdH��Z5dIdJ��Z6���Z7S�)Pr���z� A task is a language feature that represents a call to a module, with given arguments and other parameters. A handler is a subclass of a task. Usage: Task.load(datastructure) -> Task Task.something(...) �dict)�isa�default�string)r����intr����async)r���r����alias�list�����bool�class)r���Z class_typer���T)r���Zstatic����)r���ZprivateNc��������������������s<���||�_�d|�_d|�_d|�_|r$||�_n||�_tt|������dS�)zQ constructors a task, without the Task.load classmethod, it will be pretty blank NF)�_role�_parent�implicit�resolved_action�superr����__init__)�self�block�role�task_include�� __class__���9/usr/lib/python3.9/site-packages/ansible/playbook/task.pyr.���Y���s����z Task.__init__c�����������������C���s^���|�j�r|�j�j|d�}|�j�r.|�jr.d||�jf�S�|�jr:|�jS�|�j�rNd||�jf�S�d|�jf�S�dS�)z return the name of the task )�include_role_fqcnz%s : %sz%sN)r)����get_name�name�action)r/���r7���Z role_namer5���r5���r6���r8���h���s����z Task.get_namec�����������������C���sf���|d�u�rdS�t�|t�r|S�t�|t�rbd}|���D�]$\}}|�d�rDq0|d||f��}q0|���}|S�d�S�)N���_z%s=%s )� isinstancer���r����items� startswith�strip)r/����ds�buf�k�vr5���r5���r6���� _merge_kvx���s���� zTask._merge_kvc�����������������C���s���t�|||d�}|j|�||d�S�)N)r0���r1���r2���)�variable_manager�loader)r���Z load_data)�datar0���r1���r2���rF���rG����tr5���r5���r6����load����s����z Task.loadc�����������������C���s,���|�����tjv�rd|�jd��S�d|������S�dS�)z5 returns a human readable representation of the task zTASK: meta (%s)�_raw_paramszTASK: %sN)r8����CZ_ACTION_META�args�r/���r5���r5���r6����__repr__����s����z Task.__repr__c�����������������C���sb���|��d�}|�d�dus&|�d�dur6td|�|d��|du�rNtd|�|d��||d<�||d<�dS�)z2 take a lookup plugin name and store it correctly �with_�loopN� loop_withzduplicate loop in task: %s��objz&you must specify a value when using %s)�removeprefix�getr���)r/���rA����new_dsrC���rD���Z loop_namer5���r5���r6����_preprocess_with_loop����s���� zTask._preprocess_with_loopc�������������� ������sR��t�|t�std|t|�f���t��}t�|t�r6|j|_tj}|� d�}|du�rV|�j }n|��d|�j� d�|d�}|r�|�j s�|r�||vr�|�d|��n|g}|r�d|vr�d|vr�|�d��|r�||d<�t||d�}z|���\}}}W�n@�t�y �} �z&| jr���tt| �|| d��W�Y�d} ~ nd} ~ 0�0�|j|�_|tjv��rld |v��rl|� d d�dk�r^td|d ��|�d �|d <�||d<�||d<�||d<�d|v��r�|��d|� d��|d<�n t��|d<�|���D�]�\} }| dv��s�| |k�s�| dk�r�q�nZ| �d��r| �d�tv��r|��||| |��n,tj �s&| |�jv��r0||| <�nt!�"d| ����q�t#t$|���%|�S�)zg tasks are especially complex arguments so need pre-processing. keep it short. z%ds (%s) should be a dict but was a %s�collectionsNr���zansible.builtinzansible.legacy)Ztask_dsZcollection_list)rT���Zorig_exc�cmdrK���r;���z{The 'cmd' argument cannot be used when other raw parameters are specified. Please put everything in one or the other place.rS���r:���rM����delegate_to�vars)r:���Zlocal_actionrM���r[����shellrP���zIgnoring invalid attribute: %s)&r=���r���r ����typer���r ���Zansible_posr����default_collectionrV���rY���Zget_validated_value�fattributesr)����insert�appendr����parser���rT���r ���r,���rL���Z_ACTION_HAS_CMDr����popZ _load_varsr>���r?���rU���r���rX���ZINVALID_TASK_ATTRIBUTE_FAILED�display�warningr-���r����preprocess_data)r/���rA���rW���r_���Zcollections_listZargs_parserr:���rM���r[����erC���rD���r3���r5���r6���rg�������sb���� ( � zTask.preprocess_datac�����������������C���s*���t�|t�std|d��tj||�j|�jd�S�)Nz|the `loop_control` value must be specified as a dictionary and cannot be a variable itself (though it can contain variables)rS���)rH���rF���rG���)r=���r���r���r���rJ���Z_variable_manager�_loader)r/����attrrA���r5���r5���r6����_load_loop_control����s���� �zTask._load_loop_controlc�������������� ������sP���zt�t|���|��W�n6�tyJ�}�z|�jd7��_|�W�Y�d�}~n d�}~0�0�d�S�)Nzb This error can be suppressed as a warning using the "invalid_task_attribute_failed" configuration)r-���r����_validate_attributesr����message)r/���rA���rh���r3���r5���r6���rl�����s ����zTask._validate_attributesc�����������������C���s���t�|t�st|�||g��d�S��N�r=���r$����setattr�r/���rj���r9����valuer5���r5���r6����_validate_changed_when��s���� zTask._validate_changed_whenc�����������������C���s���t�|t�st|�||g��d�S�rn���ro���rq���r5���r5���r6����_validate_failed_when��s���� zTask._validate_failed_whenc��������������������s,���|�j�r|�j��|��tjrtt|���|��dS�)z� Override of base class post_validate, to also do final validation on the block and task include (if any) to which this task belongs. N)r*���� post_validater���r_���r-���r���)r/����templarr3���r5���r6���ru�����s����zTask.post_validatec�����������������C���s`���||�_�|�|�}d|v�r\|�d�}t|t�rLtjr<t�d��|� |��|}nt d|��d���|S�)NZ_variable_paramsz�Using a variable for a task's 'args' is unsafe in some situations (see https://docs.ansible.com/ansible/devel/reference_appendices/faq.html#argsplat-unsafe)z invalid or malformed argument: '�')Zuntemplated_args�templaterd���r=���r���rL���ZINJECT_FACTS_AS_VARSre���rf����updater���)r/���rj���rr���rv���rM���Zvariable_paramsr5���r5���r6����_post_validate_args%��s���� zTask._post_validate_argsc�����������������C���s���|S�)z� Override post validation for the loop field, which is templated specially in the TaskExecutor class when evaluating loops. r5����r/���rj���rr���rv���r5���r5���r6����_post_validate_loop=��s����zTask._post_validate_loopc��������������������s����i���|dur�����fdd�}t�|t�r�|D�]X}t�|t�rR|D�]}||||���q<q*�j|dd�}t�|t�rt��|O���q*t�d|���q*n8t�|t�r�t����|D�]}||||���q�n�j|dd�����S�)zu Override post validation of vars on the play, as we don't want to template these too early. Nc�������������� ������st���z�j�|dd���|�<�W�nX�tyn�}�z@t|�}�jtjv�rBd|v�sJd|v�rXW�Y�d�}~d�S���W�Y�d�}~n d�}~0�0�d�S�)NF�Zconvert_barezansible_facts.envZansible_env)rx���r���r ���r:���rL���Z_ACTION_FACT_GATHERING)rC���rD���rh����error��envr/���rv���r5���r6���� _parse_env_kvL��s����z6Task._post_validate_environment.<locals>._parse_env_kvFr}���z/could not parse environment value, skipping: %s)r=���r$���r���rx���re���rf���)r/���rj���rr���rv���r����Zenv_itemrC���Zisdictr5���r���r6����_post_validate_environmentD��s$���� zTask._post_validate_environmentc�����������������C���s���|S�)z� changed_when is evaluated after the execution of the task is complete, and should not be templated during the regular post_validate step. r5���r{���r5���r5���r6����_post_validate_changed_whenm��s����z Task._post_validate_changed_whenc�����������������C���s���|S�)z� failed_when is evaluated after the execution of the task is complete, and should not be templated during the regular post_validate step. r5���r{���r5���r5���r6����_post_validate_failed_whent��s����zTask._post_validate_failed_whenc�����������������C���s���|S�)z� until is evaluated after the execution of the task is complete, and should not be templated during the regular post_validate step. r5���r{���r5���r5���r6����_post_validate_until{��s����zTask._post_validate_untilc�����������������C���sD���t���}|�jr||�j���O�}||�jO�}d|v�r2|d=�d|v�r@|d=�|S�)N�tagsZwhen)r���r*����get_varsr\����r/���Zall_varsr5���r5���r6���r�������s���� z Task.get_varsc�����������������C���s4���t���}|�jr||�j���O�}|�jtjv�r0||�jO�}|S�rn���)r���r*����get_include_paramsr:���rL���Z_ACTION_ALL_INCLUDESr\���r����r5���r5���r6���r�������s���� zTask.get_include_paramsFc��������������������s^���t�t|�����}d�|_|�jr.|s.|�jj|d�|_d�|_|�jrB|�j|_|�j|_|�j|_|�j|_|S�)N)� exclude_tasks)r-���r����copyr*���r)���r+���r,���Z_uuid)r/���Zexclude_parentr����Znew_mer3���r5���r6���r�������s���� z Task.copyc��������������������sh���t�t|�����}|�jsd|�jsd|�jr<|�j���|d<�|�jjj|d<�|�jrP|�j���|d<�|�j |d<�|�j |d<�|S�)N�parent�parent_typer1���r+���r,���)r-���r���� serializeZ _squashedZ _finalizedr*���r4����__name__r)���r+���r,���)r/���rH���r3���r5���r6���r�������s���� zTask.serializec����������� ���������s����ddl�m}�ddlm}�|�dd��}|rv|�d�}|dkrBt��}n|dkrR|��}n|dkr`|��}|�|��||�_|d=�|�d �}|r�t��}|�|��||�_ |d =�|�d d�|�_ |�d�|�_tt |���|��d�S�) Nr�����TaskInclude)�HandlerTaskIncluder����r����r���r����r����r1���r+���Fr,���)�ansible.playbook.task_includer����Z%ansible.playbook.handler_task_includer����rV���r����deserializer*���r���r)���r+���r,���r-���r���) r/���rH���r����r����Zparent_datar�����pZ role_data�rr3���r5���r6���r�������s.���� zTask.deserializec�����������������C���s���||�_�|�jr|�j�|��dS�)z� Sets the loader on this object and recursively on parent, child objects. This is used primarily after the Task has been serialized/deserialized, which does not preserve the loader. N)ri���r*���� set_loader)r/���rG���r5���r5���r6���r�������s����zTask.set_loaderc����������� ������C���s����|�j�|�}|j}|j}z�|r"t}nt|�d|���t�}t|�jdd�rJ|�j}n|�jj}|r�|tu�sb|r�t|dd�r�|dkr�t|d�r�|�|�}nt|d|���t�}|r�|��|||�}n|}W�n�t y����Y�n0�|S�)zZ Generic logic to get the attribute or parent attribute for a task value. r<���Zstatically_loadedTr\����_get_parent_attribute) r`����extend�prependr����getattrr*����hasattrr����Z _extend_value�KeyError) r/���rj���ZomitZfattrr����r����rr���r*���Zparent_valuer5���r5���r6���r�������s*���� zTask._get_parent_attributec�����������������C���s���|�j�r|�j����S�dS�)NT)r*����all_parents_staticrN���r5���r5���r6���r������s���� zTask.all_parents_staticc�����������������C���s2���ddl�m}�|�jr.t|�j|�r$|�jS�|�j���S�d�S�)Nr���r����)r����r����r*���r=����get_first_parent_include)r/���r����r5���r5���r6���r������s���� zTask.get_first_parent_include)NNN)T)NNNNN)FF)F)8r����� __module__�__qualname__�__doc__r���r���rM���r:���Z async_valr$���Zchanged_whenZdelayr���r[���Zdelegate_factsZfailed_whenrQ���r���Zloop_control�notifyrL���ZDEFAULT_POLL_INTERVALZpoll�registerZretriesZuntilrR���r.���r8���rE����staticmethodrJ���rO���rX���rg���rk���rl���rs���rt���ru���rz���r|���r����r����r����r����r����r����r����r����r����r����r����r����r����� __classcell__r5���r5���r3���r6���r���.���sZ��� _ ) (N)3Z __future__r���r���r���r^���Z __metaclass__Zansibler���rL���Zansible.errorsr���r���r���r ���Zansible.module_utils._textr ���Zansible.module_utils.sixr���Zansible.parsing.mod_argsr���Zansible.parsing.yaml.objectsr ���r���Zansible.plugins.loaderr���Zansible.playbook.attributer���r���Zansible.playbook.baser���Zansible.playbook.blockr���Z!ansible.playbook.collectionsearchr���Zansible.playbook.conditionalr���Zansible.playbook.loop_controlr���Zansible.playbook.roler���Zansible.playbook.taggabler���Zansible.utils.collection_loaderr���Zansible.utils.displayr���Zansible.utils.sentinelr����__all__re���r���r5���r5���r5���r6����<module>���s,���