a )gt@sddlmZmZmZeZdZddlZddlm Z ddl m Z ddl mZmZmZddlmZddlmZdd lmZdd lmZiZGd d d eZdS) )absolute_importdivisionprint_functionaV name: host_group_vars version_added: "2.4" short_description: In charge of loading group_vars and host_vars requirements: - Enabled in configuration description: - Loads YAML vars into corresponding groups/hosts in group_vars/ and host_vars/ directories. - Files are restricted by extension to one of .yaml, .json, .yml or no extension. - Hidden (starting with '.') and backup (ending with '~') files and directories are ignored. - Only applies to inventory sources that are existing paths. - Starting in 2.10, this plugin requires enabling and is enabled by default. options: stage: ini: - key: stage section: vars_host_group_vars env: - name: ANSIBLE_VARS_PLUGIN_STAGE _valid_extensions: default: [".yml", ".yaml", ".json"] description: - "Check all of these extensions when looking for 'variable' files which should be YAML or JSON or vaulted versions of these." - 'This affects vars_files, include_vars, inventory and vars plugins among others.' env: - name: ANSIBLE_YAML_FILENAME_EXT ini: - key: yaml_valid_extensions section: defaults type: list elements: string extends_documentation_fragment: - vars_plugin_staging N) constants)AnsibleParserError)to_bytes to_nativeto_text)BaseVarsPlugin)Host)Group) combine_varscs"eZdZdZdfdd ZZS) VarsModuleTc st|ts|g}tt||||i}|D]L}t|trBd}n t|trRd}ntdt||j t j j s,zg}t j tt j |j|} t| } d|j | f} |r| tvrt| }nXt j | rt j | r|jd| || |j }|t| <n|jd|| f|D]&} |j| ddd} | rt|| }qWq,tyx}ztt|WYd }~q,d }~00q,|S) z parses the inventory file Z host_varsZ group_varsz5Supplied entity must be Host or Group, got %s insteadz%s.%sz processing dir %sz.Found %s that is not a directory, skipping: %sT)cacheZunsafeN) isinstancelistsuperrget_varsr r rtypename startswithospathseprealpathrjoinZ_basedirr FOUNDexistsisdirZ_displaydebugZfind_vars_filesZwarningZload_from_filer Exceptionr)selfloaderrZentitiesrdataZentityZsubdirZ found_filesZb_opathZopathkeyfoundZnew_datae __class__H/usr/lib/python3.9/site-packages/ansible/plugins/vars/host_group_vars.pyrHs>       $zVarsModule.get_vars)T)__name__ __module__ __qualname__ZREQUIRES_ENABLEDr __classcell__r)r)r'r*rDsr)Z __future__rrrrZ __metaclass__Z DOCUMENTATIONrZansiblerCZansible.errorsrZansible.module_utils._textrrr Zansible.plugins.varsr Zansible.inventory.hostr Zansible.inventory.groupr Zansible.utils.varsr rrr)r)r)r*s#