a )g@sddlmZmZmZeZddlmZddl m Z ddl m Z ddl mZddlmZddlmZdgZeZGd ddeZdS) )absolute_importdivisionprint_functionN)AnsibleParserError)Block)Task)Display)Sentinel TaskIncludecseZdZdZedZedZeeZedZ dfdd Z e ddd Z d d Z fd d Zdfdd ZfddZddZZS)r z A task include is derived from a regular task to handle the special circumstances related to the `- include: ...` task. )file _raw_params)apply)actionargs collectionsZdebugger ignore_errorsZloopZ loop_controlZ loop_withnameZno_logregisterZrun_oncetagstimeoutvarswhenNcs tt|j|||dd|_dS)Nblockrole task_includeF)superr __init__statically_loaded)selfrrr __class__A/usr/lib/python3.9/site-packages/ansible/playbook/task_include.pyr0szTaskInclude.__init__cCs*t|||d}||j|||d|}|S)Nr)variable_managerloader)r check_optionsZ load_data)datarrrr$r%Ztitaskr"r"r#load4s zTaskInclude.loadcCst|j}||j}|rJ|jtjvrJtd|jd t |f|d|j ds|j dd|jd<|jdstd|j|j di}|r|jtj vrtd |j|dnt|tstd 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) frozensetrkeys difference VALID_ARGSrCZ'_ACTION_ALL_PROPER_INCLUDE_IMPORT_TASKSrjoinlistgetpopZ_ACTION_INCLUDE_TASKS isinstancedicttype)rr(r'Z my_arg_namesZbad_opts apply_attrsr"r"r#r&>s     zTaskInclude.check_optionscsztt||}t||j}|D]L}||tur(|dtj vr(tj rft d||j j f|dq(td|q(|S)Nrz&'%s' is not a valid attribute for a %sr+zIgnoring invalid attribute: %s)rr preprocess_datasetr.r/VALID_INCLUDE_KEYWORDSr r1Z_ACTION_ALL_INCLUDE_ROLE_TASKSZINVALID_TASK_ATTRIBUTE_FAILEDrr!__name__displayZwarning)rZdsdiffkr r"r#r:YszTaskInclude.preprocess_dataFcs tt|j||d}|j|_|S)N)exclude_parent exclude_tasks)rr copyr)rrArBZnew_mer r"r#rCgszTaskInclude.copycsj|jtjvrtt|}nJt}|jr6||jO}||jO}||j O}d|vrX|d=d|vrf|d=|S)z We override the parent Task() classes get_vars here because we need to include the args of the include into the vars as they are params to the included tasks. But ONLY for 'include' rr) rr1Z_ACTION_INCLUDErr get_varsr7_parentrr)rZall_varsr r"r#rDls   zTaskInclude.get_varscCsD|jdi}|rr r"r"r"r#s