o nnh|@stddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdgZe ZGd dde ZdS) ) annotationsN)AnsibleParserError)Block)Task)Display)Sentinel TaskIncludecs|eZdZdZedZedZeeZedZ dfdd Z e ddd Z d d Z fd d Zdfdd ZddZZS)rz A task include is derived from a regular task to handle the special circumstances related to the `- include_*: ...` task. )file _raw_params)apply)actionargs collectionsdebugger ignore_errorsloop loop_control loop_withnameno_logregisterrun_oncetagstimeoutvarswhenNcs tt|j|||dd|_dS)Nblockrole task_includeF)superr__init__statically_loaded)selfrrr __class__H/usr/local/lib/python3.10/dist-packages/ansible/playbook/task_include.pyr!.s zTaskInclude.__init__cCs*t|||d}||j|||d|}|S)Nr)variable_managerloader)r check_options load_data)datarrrr(r)titaskr&r&r'load2s zTaskInclude.loadcCst|j}||j}|r%|jtjvr%td|jd t |f|d|j dsC|j dd|jd<|jdsCtd|j|d|j di}|r[|jtj vr[td |j|dt|tsjtd t||d|S) aV Method for options validation to use in 'load_data' for TaskInclude and HandlerTaskInclude since they share the same validations. It is not named 'validate_options' on purpose to prevent confusion with '_validate_*" methods. Note that the task passed might be changed as a side-effect of this method. zInvalid options for %s: %s,objr r NzNo file specified for %sr zInvalid options for %s: applyz,Expected a dict for apply but got %s instead) frozensetr keys difference VALID_ARGSr C'_ACTION_ALL_PROPER_INCLUDE_IMPORT_TASKSrjoinlistgetpop_ACTION_INCLUDE_TASKS isinstancedicttype)r#r.r, my_arg_namesbad_opts apply_attrsr&r&r'r*<s     zTaskInclude.check_optionscsxtt||}t||j}|D]%}||tur9|dtj vr9tj r2t d||j j f|dtd|q|S)Nr z&'%s' is not a valid attribute for a %sr1zIgnoring invalid attribute: %s)r rpreprocess_datasetr4r5VALID_INCLUDE_KEYWORDSrr7_ACTION_ALL_INCLUDE_ROLE_TASKSINVALID_TASK_ATTRIBUTE_FAILEDrr%__name__displaywarning)r#dsdiffkr$r&r'rDWszTaskInclude.preprocess_dataFcs tt|j||d}|j|_|S)N)exclude_parent exclude_tasks)r rcopyr")r#rOrPnew_mer$r&r'rQeszTaskInclude.copycCsF|jdi}|rg|d<tj||jj||j|j|jd}|S|}|S)z{ This method is used to create the parent block for the included tasks when ``apply`` is specified r r)playrrr(r)) r r<rr/_parent_play_role_variable_manager_loader)r#rCp_blockr&r&r'build_parent_blockjs zTaskInclude.build_parent_block)NNN)NNNNN)FF)rI __module__ __qualname____doc__r3BASE OTHER_ARGSunionr6rFr! staticmethodr/r*rDrQrZ __classcell__r&r&r$r'r s   ) __future__ransible.constants constantsr7ansible.errorsransible.playbook.blockransible.playbook.taskransible.utils.displayransible.utils.sentinelr__all__rJrr&r&r&r's