HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible/plugins/inventory/__pycache__/yaml.cpython-39.pyc
a

�)g�@s�ddlmZmZmZeZdZdZddlZddl	m
Z
ddlmZm
Z
ddlmZddlmZmZdd	lmZed�ZGd
d�de�ZdS)�)�absolute_import�division�print_functiona�
    name: yaml
    version_added: "2.4"
    short_description: Uses a specific YAML file as an inventory source.
    description:
        - "YAML-based inventory, should start with the C(all) group and contain hosts/vars/children entries."
        - Host entries can have sub-entries defined, which will be treated as variables.
        - Vars entries are normal group vars.
        - "Children are 'child groups', which can also have their own vars/hosts/children and so on."
        - File MUST have a valid extension, defined in configuration.
    notes:
        - If you want to set vars for the C(all) group inside the inventory file, the C(all) group must be the first entry in the file.
        - Enabled in configuration by default.
    options:
      yaml_extensions:
        description: list of 'valid' extensions for files containing YAML
        type: list
        elements: string
        default: ['.yaml', '.yml', '.json']
        env:
          - name: ANSIBLE_YAML_FILENAME_EXT
          - name: ANSIBLE_INVENTORY_PLUGIN_EXTS
        ini:
          - key: yaml_valid_extensions
            section: defaults
          - section: inventory_plugin_yaml
            key: yaml_valid_extensions

a�
all: # keys must be unique, i.e. only one 'hosts' per group
    hosts:
        test1:
        test2:
            host_var: value
    vars:
        group_all_var: value
    children:   # key order does not matter, indentation does
        other_group:
            children:
                group_x:
                    hosts:
                        test5   # Note that one machine will work without a colon
                #group_x:
                #    hosts:
                #        test5  # But this won't
                #        test7  #
                group_y:
                    hosts:
                        test6:  # So always use a colon
            vars:
                g2_var2: value3
            hosts:
                test4:
                    ansible_host: 127.0.0.1
        last_group:
            hosts:
                test1 # same host as above, additional group membership
            vars:
                group_last_var: value
N)�MutableMapping)�AnsibleError�AnsibleParserError)�string_types)�	to_native�to_text)�BaseFileInventoryPlugincsJeZdZdZ�fdd�Z�fdd�Zd
�fdd�	Zd	d
�Zdd�Z�Z	S)�InventoryModuleZyamlcstt|���dS)N)�superr�__init__)�self��	__class__��B/usr/lib/python3.9/site-packages/ansible/plugins/inventory/yaml.pyrUszInventoryModule.__init__cs>d}tt|��|�r:tj�|�\}}|r6||�d�vr:d}|S)NFZyaml_extensionsT)r
r�verify_file�os�path�splitextZ
get_option)rrZvalid�	file_name�extrrrrYszInventoryModule.verify_fileTc
s�tt|��|||�|��z|jj|dd�}Wn,ty\}zt|��WYd}~n
d}~00|sltd��n.t|t	�s�tdt
|���n|�d�r�td��t|t	�r�|D]}|�|||�q�ntdt
|���dS)	z parses the inventory file F)�cacheNzParsed empty YAML filezHYAML inventory has invalid structure, it should be a dictionary, got: %sZpluginz2Plugin configuration YAML file, not YAML inventoryz8Invalid data from file, expected dictionary and got:

%s)r
r�parseZset_options�loaderZload_from_file�	Exceptionr�
isinstancer�type�get�_parse_groupr	)r�	inventoryrrr�data�eZ
group_namerrrrbs 



zInventoryModule.parsec
Cst|ttf��r�z|j�|�}Wn8tyX}z td|t|�f��WYd}~n
d}~00|du�rdD]V}||vrht||t�r�||di||<t||ttf�shtd||t	||�f��qh|D�]*}t||ttf�s�|j
�d||t	||�f�q�t||t��r"|j
�d||f�q�|dk�rV||D]}|j�
|||||��q4q�|dk�r�||D](}|�||||�}|j�||��qhq�|dk�r�||D]2}|�|�\}	}
|�|	|||�p�i||
��q�q�|j
�d	||f�q�n|j
�d
|�|S)NzUnable to add group %s: %s)�vars�children�hostszMInvalid "%s" entry for "%s" group, requires a dictionary, found "%s" instead.zBSkipping key (%s) in group (%s) as it is not a mapping, it is a %sz%Skipping empty key (%s) in group (%s)r%r&r'zYSkipping unexpected key (%s) in group (%s), only "vars", "children" and "hosts" are validz5Skipping '%s' as this is not a valid group definition)rr�NoneTyper"�	add_grouprrr
rrZdisplayZwarningZvvvZset_variabler!Z	add_child�_parse_hostZ_populate_host_vars)r�groupZ
group_datar$�section�key�varZsubgroup�host_patternr'�portrrrr!|sD*
�



$zInventoryModule._parse_groupcCs>z|�|�\}}Wn"ty4td|�d���Yn0||fS)z_
        Each host key can be a pattern, try to process it and add variables as needed
        z
Host pattern z> must be a string. Enclose integers/floats in quotation marks.)Z_expand_hostpattern�	TypeErrorr)rr/Z	hostnamesr0rrrr*�s
�
zInventoryModule._parse_host)T)
�__name__�
__module__�__qualname__�NAMErrrr!r*�
__classcell__rrrrrQs	1r)Z
__future__rrrrZ
__metaclass__Z
DOCUMENTATIONZEXAMPLESr�collections.abcrZansible.errorsrrZansible.module_utils.sixrZansible.module_utils._textr	r
Zansible.plugins.inventoryrr(rrrrr�<module>s!