a )g@sddlmZmZmZeZddlZddlmZ ddl m Z m Z ddl mZddlmZddlmZmZddlmZmZddlmZdd lmZdd lmZdd lmZdd lm Z dd l!m"Z"m#Z#ddl$m%Z%ddl&m'Z'e'Z(GdddeeeZ)dS))absolute_importdivisionprint_functionN)AnsibleParserErrorAnsibleAssertionError)to_bytes) string_types) split_argsparse_kv)AnsibleBaseYAMLObjectAnsibleMapping)NonInheritableFieldAttribute)Base) Conditional)Taggable)AnsibleCollectionConfig)_get_collection_name_from_path_get_collection_playbook_path)Templar)DisplaycsXeZdZeddZededdZedddZdfd d Z fd d Z d dZ Z S)PlaybookIncludestring)isadictvars)rdefaultaliasNcCstj||||dS)N)dsbasedirvariable_managerloader)r load_data)datarrr r#E/usr/lib/python3.9/site-packages/ansible/playbook/playbook_include.pyload/szPlaybookInclude.loadc sddlm}ddlm}tt||||}|j}|rF|| O}t ||d} ||d} | |j } t | } | dur| d} | d}n&| } tj| stj|| } t| }|r|t_n$tjtjtjt| d d | j| ||jd | jD]}|jr$t||r$|jdd|_|j|jB}|d d}|durX|j !|"d ||_t#t$|j %|j |_ |j&durtj| |_&|jr|j'|j(|j)|j*D]$}|jdd|jdd|_+qq| S)z Overrides the base load_data(), as we're actually going to return a new Playbook() object rather than a PlaybookInclude object r)Playbook)Play)r Z variables)r NZsurrogate_or_strict)errors) file_namerrtags,),Zansible.playbookr&Zansible.playbook.playr'superrr!rcopyZget_varsrtemplateimport_playbookrospathisabsjoinrrZdefault_collectionZplaybook_pathsappenddirnameabspathrZ_load_playbook_dataZ_entriesZwhen isinstanceZ_included_conditionalpopr,extendsplitlistsetunionZ_included_pathZ pre_tasksZrolesZtasksZ post_tasksZ_when)selfrrrr r&r'Znew_objZall_varsZtemplarZpbr+resourceZplaybookZplaybook_collectionentryZ temp_varsZ param_tagsZ task_block __class__r#r$r!3sH         $     $zPlaybookInclude.load_datacst|tstd|t|ft}t|tr6|j|_|D]`\}}|tj vrb| ||||q>|dkrd|vrt d|dnt|tst d|d|||<q>t t ||S)z Regorganizes the data for a PlaybookInclude datastructure to line up with what we expect the proper attributes to be z%ds (%s) should be a dict but was a %srzTimport_playbook parameters cannot be mixed with 'vars' entries for import statementsobjzEvars for import_playbook statements must be specified as a dictionary)r9rrtyper r Z ansible_positemsCZ_ACTION_IMPORT_PLAYBOOK_preprocess_importrr.rpreprocess_data)r@rnew_dskvrCr#r$rK~s      zPlaybookInclude.preprocess_datacCsh|durtd|dnt|ts4tdt||dt|}t|dkrTtd|d|d|d<dS)zQ Splits the playbook import line up into filename and parameters Nz$playbook import parameter is missingrEzQplaybook import parameter must be a string indicating a file path, got %s insteadrz?import_playbook statements must specify the file name to importr1)rr9rrGr lenstrip)r@rrLrMrNrHr#r#r$rJs   z"PlaybookInclude._preprocess_import)NN)NN) __name__ __module__ __qualname__r r1rZvars_val staticmethodr%r!rKrJ __classcell__r#r#rCr$r*s  K r)*Z __future__rrrrGZ __metaclass__r2Zansible.constantsZ constantsrIZansible.errorsrrZansible.module_utils._textrZansible.module_utils.sixrZansible.parsing.splitterr r Zansible.parsing.yaml.objectsr r Zansible.playbook.attributer Zansible.playbook.baserZansible.playbook.conditionalrZansible.playbook.taggablerZansible.utils.collection_loaderrZ2ansible.utils.collection_loader._collection_finderrrZansible.templaterZansible.utils.displayrZdisplayrr#r#r#r$s$