
    Vh                        d dl mZ dZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d d	lmZ i Zi Z e       Zi Z G d
 de	      Zy)    )annotationsaV  
    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)AnsibleParserError)	to_native)BaseVarsPlugin)basedir)InventoryObjectType)combine_varsc                  "    e Zd ZdZdZd ZddZy)
VarsModuleTc                Z    |D ]%  }|j                  |dd      }|st        ||      }' |S )NallT)cacheunsafe)load_from_filer	   )selfloaderdatafound_filesfoundnew_datas         T/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/vars/host_group_vars.pyload_found_fileszVarsModule.load_found_filesJ   s>      	4E,,U%,MH#D(3	4     c                   t        |t              s|g}	 t        |   }i }|D ]  }	 |j                  }	 |d   }	|	t        j
                  j                  k7  s5	 g }
	 |j                  }|t         j"                  u rd}n,|t         j$                  u rd}nt        dt        |      z        |r?	 t&        ||f   }|t*        v r|d|}|t,        v rF| j/                  ||t,        |         }t        j
                  j)                  ||      x}t&        ||f<   t        j
                  j1                  |      r:| j2                  j5                  d|z         |j7                  ||      xt,        <   }
nkt        j
                  j9                  |      st*        j;                  |       n6| j2                  j=                  d|d|       t*        j;                  |       | j/                  |||
      } |S # t        $ r5 t        j
                  j                  t        |            xt        |<   }Y w xY w# t        $ r t        dt        |      z        w xY w# t        t        t        f$ r t        dt        |      z        w xY w# t        $ r t        dt        |      z        w xY w# t        $ r/ t        j
                  j)                  ||      x}t&        ||f<   Y )w xY w# t>        $ r}t        tA        |            d	}~ww xY w)
z parses the inventory file z5Supplied entity must be Host or Group, got %s insteadr   	host_vars
group_vars.z	processing dir %szFound z$ that is not a directory, skipping: N)!
isinstancelistCANONICAL_PATHSKeyErrorospathrealpathr   nameAttributeErrorr   type	TypeError
IndexErrorsep	base_typer   HOSTGROUP
PATH_CACHEjoinNAKFOUNDr   isdir_displaydebugfind_vars_filesexistsaddwarning	Exceptionr   )r   r   r#   entitiesr   realpath_basedirr   entityentity_name
first_charr   entity_typesubdiropathkeyes                   r   get_varszVarsModule.get_varsQ   s    (D) zH	W.t4  9	;Fs$kks(^

 RWW[[(,;"$K{&,&6&6 #&9&>&>>!,$(;(A(AA!-01hlpqwlx1yzzt$.0@&/I$JE !C<$)4e<%<#'#8#8uSz#RD$IKVfhnIoo
,<f+E Fww}}U+++,AE,IJ393I3I%Q\3]]c
[WW^^E2--bhjo.pq00{KDm9	;t }  	W79ww7G7GPT7VVOD!$4	W " s()`dhiodp)qrrs
 z84 s()`dhiodp)qrrs * {01hlpqwlx1yzz{  ( tMOWW\\ZjlrMssEJ0@&/I$Jt2 ! ;,Yq\::;s   	G0 H1IK#J'AK#+J(6K#?)K#)DK#0:H.-H.1!I,J!J%%K#(4K K#K  K##	L,L  LN)T)__name__
__module____qualname__REQUIRES_ENABLEDis_statelessr   rD    r   r   r   r   E   s    LGr   r   )
__future__r   DOCUMENTATIONr"   ansible.errorsr   +ansible.module_utils.common.text.convertersr   ansible.plugins.varsr   ansible.utils.pathr   ansible.inventory.groupr   ansible.utils.varsr	   r    r1   setr0   r.   r   rJ   r   r   <module>rT      sM   $ #!F 
 - A / & 7 +
	e
S Sr   