
    Vh                    r    d dl mZ dZdZd dlZd dlmZmZ d dlm	Z	m
Z
mZ d dlmZ d dlmZ  G d	 d
e      Zy)    )annotationsa  
    name: host_list
    version_added: "2.4"
    short_description: Parses a 'host list' string
    description:
        - Parses a host list string as a comma separated values of hosts
        - This plugin only applies to inventory strings that are not paths and contain a comma.
a  
    # define 2 hosts in command line
    # ansible -i '10.10.2.6, 10.10.2.4' -m ping all

    # DNS resolvable names
    # ansible -i 'host1.example.com, host2' -m user -a 'name=me state=absent' all

    # just use localhost
    # ansible-playbook -i 'localhost,' play.yml -c local
N)AnsibleErrorAnsibleParserError)to_bytes	to_nativeto_text)parse_address)BaseInventoryPluginc                  *     e Zd ZdZd Zd fd	Z xZS )InventoryModule	host_listc                n    d}t        |d      }t        j                  j                  |      sd|v rd}|S )NFsurrogate_or_strict)errors,T)r   ospathexists)selfr   validb_paths       S/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/inventory/host_list.pyverify_filezInventoryModule.verify_file&   s5    ),ABww~~f%#*:E    c                   t         t        |   |||       	 |j                  d      D ]]  }|j	                         }|s	 t        |d      \  }}|| j                  j                  vs@| j                  j                  |d|       _ y# t        $ r5}| j                  j                  dt        |      z         |}d}Y d}~sd}~ww xY w# t        $ r}t        dt        |      z        d}~ww xY w)	z parses the inventory file r   F)allow_rangesz<Unable to parse address from hostname, leaving unchanged: %sN	ungrouped)groupportz-Invalid data from string, could not parse: %s)superr   parsesplitstripr	   r   displayvvvr   	inventoryhostsadd_host	Exceptionr   r   )
r   r&   loaderr   cachehhostr   e	__class__s
            r   r!   zInventoryModule.parse.   s     	ot*9fiH	e__S) TGGI$'4QU'Kt 4>>#7#77//Kd/ST
 ( $(()gjqrsjt)tu #$  	e$%TW`abWc%cdd	esG   &C  B
C ) C 
	C+C>C CC 	C0C++C0)T)__name__
__module____qualname__NAMEr   r!   __classcell__)r/   s   @r   r   r   "   s    De er   r   )
__future__r   DOCUMENTATIONEXAMPLESr   ansible.errorsr   r   +ansible.module_utils.common.text.convertersr   r   r   ansible.parsing.utils.addressesr	   ansible.plugins.inventoryr
   r    r   r   <module>r=      s;    #	 
 ; T T 9 9e) er   