AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.133.131.251
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python2.7/site-packages/ansible/plugins/inventory/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyc
�
��\c@`s�ddlmZmZmZeZdZdZddlZddl	Z	ddl
mZmZm
Z
ddlmZddlmZmZddlmZmZdd	lmZd
efd��YZdS(i(tabsolute_importtdivisiontprint_functions<
    inventory: ini
    version_added: "2.4"
    short_description: Uses an Ansible INI file as inventory source.
    description:
        - INI file based inventory, sections are groups or group related with special `:modifiers`.
        - Entries in sections C([group_1]) are hosts, members of the group.
        - Hosts can have variables defined inline as key/value pairs separated by C(=).
        - The C(children) modifier indicates that the section contains groups.
        - The C(vars) modifier indicates that the section contains variables assigned to members of the group.
        - Anything found outside a section is considered an 'ungrouped' host.
        - Values passed in using the C(key=value) syntax are interpreted as Python literal structure (strings, numbers, tuples, lists, dicts,
          booleans, None), alternatively as string. For example C(var=FALSE) would create a string equal to 'FALSE'. Do not rely on types set
          during definition, always make sure you specify type with a filter when needed when consuming the variable.
    notes:
        - It takes the place of the previously hardcoded INI inventory.
        - To function it requires being whitelisted in configuration.
        - Variable values are processed by Python's ast.literal_eval function (U(https://docs.python.org/2/library/ast.html#ast.literal_eval))
          which could cause the value to change in some cases. See the Examples for proper quoting to prevent changes. Another option would be
          to use the yaml format for inventory source which processes the values correctly.
s3
  example1: |
      # example cfg file
      [web]
      host1
      host2 ansible_port=222

      [web:vars]
      http_port=8080 # all members of 'web' will inherit these
      myvar=23

      [web:children] # child groups will automatically add their hosts to partent group
      apache
      nginx

      [apache]
      tomcat1
      tomcat2 myvar=34 # host specific vars override group vars
      tomcat3 mysecret="'03#pa33w0rd'" # proper quoting to prevent value changes

      [nginx]
      jenkins1

      [nginx:vars]
      has_java = True # vars in child groups override same in parent

      [all:vars]
      has_java = False # 'all' is 'top' parent

  example2: |
      # other example config
      host1 # this is 'ungrouped'

      # both hosts have same IP but diff ports, also 'ungrouped'
      host2 ansible_host=127.0.0.1 ansible_port=44
      host3 ansible_host=127.0.0.1 ansible_port=45

      [g1]
      host4

      [g2]
      host4 # same host as above, but member of 2 groups, will inherit vars from both
            # inventory hostnames are unique
N(tBaseFileInventoryPlugintdetect_rangetexpand_hostname_range(t
parse_address(tAnsibleErrortAnsibleParserError(tto_bytestto_text(tshlex_splittInventoryModulecB`s�eZdZdZed�Zed�Zd�Zed�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zed��Zd�ZRS(s�
    Takes an INI-format inventory file and builds a list of groups and subgroups
    with their associated hosts and variable settings.
    tiniu;u#t;t#cC`s)tt|�j�i|_d|_dS(N(tsuperRt__init__tpatternstNonet	_filename(tself((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyR]s	cC`sHtt|�j|||�||_y�|jrL|jj|�\}}n6t|dd�}t|d��}|j�}WdQXyt	|dd�j
�}	Wnptk
rg}	xZ|j
�D]H}
|
r�|
d|jkr�|	j
d�q�|	j
t	|
dd��q�WnX|j||	�Wntk
rC}t|��nXdS(Nterrorstsurrogate_or_stricttrbiu(RRtparseRtloadert_get_file_contentsR	topentreadR
t
splitlinestUnicodeErrortb_COMMENT_MARKERStappendt_parset	ExceptionR(Rt	inventoryRtpathtcachetb_datatprivatetb_pathtfhtdatatlinete((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyRds&		
!cC`s$td|j|jf|��dS(Ns%s:%d: (RRtlineno(Rtmessage((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyt_raise_error�scC`s�|j�i}d}d}d|_x�|D]�}|jd7_|j�}|s,|d|jkrmq,n|jdj|�}|r�|j�\}}|p�d}|dkr�dj|j��}|jd	||f�n||j	jkrD|dkr1||kr1t
d
|jd|d|�||<n|j	j|�n||kr,|dkr,||ddkr�|j||�q�||ddkr�||=q�q,q,n6|j
d
�r�|jd�r�|jd|d�n|dkr|j|�\}	}
}|j|	|||
�q,|dkrW|j|�\}}
|j	j|||
�q,|dkr�|j|�}||j	jkr�||kr�t
d
|jd|d|d|g�||<q�||dj|�q�|j	j||�q,|jd|�q,Wx�|D]�}||}|ddkrStd||d
|d|df��q|ddkrtd||d
|dj�|df��qqWdS(st
        Populates self.groups from the given array of lines. Raises an error on
        any parse failure.
        t	ungroupedthostsiitsectiontchildrentvarst:s!Section [%s] has unknown type: %sR,tstatetnamet[t]sFInvalid section entry: '%s'. Please make sure that there are no spacessDin the section entry, and that there are no other invalid characterstparentssEntered unhandled state: %ss:%s:%d: Section [%s:vars] not valid for undefined group: %ss9%s:%d: Section [%s:children] includes undefined group: %sN(shostsR4svars(t_compile_patternsR.tstript_COMMENT_MARKERSRtmatchtgroupstjoinR0R$tdictt	add_groupt_add_pending_childrent
startswithtendswitht_parse_host_definitiont_populate_host_varst_parse_variable_definitiontset_variablet_parse_group_nameR!t	add_childRtpop(RR%tlinestpending_declarationst	groupnameR7R,tmttitleR2tportt	variablestktvtchildtgtdecl((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyR"�sd
	
	%

.

+cC`sjx\||dD]L}|jj||�||kr||ddkr|j||�qqW||=dS(NR;R7R4(R$RLRD(Rtgrouptpendingtparent((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyRD�s
 cC`s>|jdj|�}|r)|jd�S|jd|�dS(s�
        Takes a single line and tries to parse it as a group name. Returns the
        group name if successful, or raises an error.
        RPisExpected group name, got: %sN(RR?RZR0(RR,RQ((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyRK�s
cC`sed|krPg|jdd�D]}|j�^q\}}||j|�fS|jd|�dS(s�
        Takes a string and tries to parse it as a variable definition. Returns
        the key and value if successful, or raises an error.
        t=isExpected key=value, got: %sN(tsplitR=t_parse_valueR0(RR,R-RURV((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyRIs1c
C`s�yt|dt�}Wn*tk
rB}|jd||f�nX|j|d�\}}i}x]|dD]Q}d|kr�|jd|�n|jdd�\}}	|j|	�||<qmW|||fS(s�
        Takes a single line and tries to parse it as a host definition. Returns
        a list of Hosts if successful, or raises an error.
        tcommentss&Error parsing host definition '%s': %siiR]s4Expected key=value host variable assignment, got: %s(RtTruet
ValueErrorR0t_expand_hostpatternR^R_(
RR,ttokensR-t	hostnamesRSRTttRURV((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyRGscC`sjyt|dt�\}}Wntk
r;|}d}nXt|�rWt|�}n	|g}||fS(s�
        Takes a single host pattern and returns a list of hostnames and an
        optional port number that applies to all of them.
        tallow_rangesN(RRaR#RRR(RthostpatterntpatternRSRe((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyRc:s	

	cC`sMytj|�}Wn!tk
r&ntk
r6nXt|dddd�S(s�
        Attempt to transform the string value from an ini file into a basic python object
        (int, dict, list, unicode string, etc).
        t	nonstringtpassthruRR(tasttliteral_evalRbtSyntaxErrorR
(RV((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyR_Ts

cC`sTtjtddd�tj�|jd<tjtddd�tj�|jd<dS(s|
        Compiles the regular expressions required to parse the inventory and
        stores them in self.patterns.
        s�^\[
                    ([^:\]\s]+)             # group name (see groupname below)
                    (?::(\w+))?             # optional : and tag name
                \]
                \s*                         # ignore trailing whitespace
                (?:\#.*)?                   # and/or a comment till the
                $                           # end of the line
            RRR3s�^
                ([^:\]\s]+)
                \s*                         # ignore trailing whitespace
                (?:\#.*)?                   # and/or a comment till the
                $                           # end of the line
            RPN(tretcompileR
tXR(R((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyR<fs(u;u#(RR(t__name__t
__module__t__doc__tNAMEt	frozensetR>R RRaRR0R"RDRKRIRGRctstaticmethodR_R<(((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyRTs	$		j				!	(t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONtEXAMPLESRlRotansible.plugins.inventoryRRRtansible.parsing.utils.addressesRtansible.errorsRRtansible.module_utils._textR	R
tansible.utils.shlexRR(((sA/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.pyt<module>s-

Anon7 - 2022
AnonSec Team