AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 18.191.165.129
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/aws_ec2.pyo
�
��\c@`s�ddlmZmZmZeZdZdZddlm	Z	ddl
mZmZddl
mZmZddl
mZddlmZmZmZmZydd	lmZWn*ek
r�dd
lmZe�ZnXyddlZddlZWnek
re	d��nXid�d6d�d6d�d6d�d6d�d6d�d6ZiLd�d6d�d6d�d6d�d#6d�d%6d�d'6d�d)6d�d+6d�d-6d�d/6d�d16d�d36d�d66d�d86d�d:6d�d<6d�d?6d�dA6d�dC6d�dE6d�dF6d�dH6d�dJ6d�dL6d�dN6d�dP6d�dR6d�dU6d�dX6d�d[6d�d]6d�d^6d�d_6d�db6d�dd6d�dg6d�dh6d�dj6d�dk6d�dl6d�dm6d�dn6d�dp6d�dq6d�dr6d�du6d�dw6d�dy6d�dz6d�d|6d�d}6d�d~6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6Zd�eeefd���YZdS(�i(tabsolute_importtdivisiontprint_functionsn
    name: aws_ec2
    plugin_type: inventory
    short_description: ec2 inventory source
    requirements:
        - boto3
        - botocore
    extends_documentation_fragment:
        - inventory_cache
        - constructed
    description:
        - Get inventory hosts from Amazon Web Services EC2.
        - Uses a YAML configuration file that ends with aws_ec2.(yml|yaml).
    options:
        plugin:
            description: token that ensures this is a source file for the 'aws_ec2' plugin.
            required: True
            choices: ['aws_ec2']
        boto_profile:
          description: The boto profile to use.
          env:
              - name: AWS_PROFILE
              - name: AWS_DEFAULT_PROFILE
        aws_access_key_id:
          description: The AWS access key to use. If you have specified a profile, you don't need to provide
              an access key/secret key/session token.
          env:
              - name: AWS_ACCESS_KEY_ID
              - name: AWS_ACCESS_KEY
              - name: EC2_ACCESS_KEY
        aws_secret_access_key:
          description: The AWS secret key that corresponds to the access key. If you have specified a profile,
              you don't need to provide an access key/secret key/session token.
          env:
              - name: AWS_SECRET_ACCESS_KEY
              - name: AWS_SECRET_KEY
              - name: EC2_SECRET_KEY
        aws_security_token:
          description: The AWS security token if using temporary access and secret keys.
          env:
              - name: AWS_SECURITY_TOKEN
              - name: AWS_SESSION_TOKEN
              - name: EC2_SECURITY_TOKEN
        regions:
          description:
            - A list of regions in which to describe EC2 instances.
            - If empty (the default) default this will include all regions, except possibly restricted ones like us-gov-west-1 and cn-north-1.
          type: list
          default: []
        hostnames:
          description: A list in order of precedence for hostname variables. You can use the options specified in
              U(http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options). To use tags as hostnames
              use the syntax tag:Name=Value to use the hostname Name_Value, or tag:Name to use the value of the Name tag.
          type: list
          default: []
        filters:
          description: A dictionary of filter value pairs. Available filters are listed here
              U(http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options)
          type: dict
          default: {}
        strict_permissions:
          description: By default if a 403 (Forbidden) is encountered this plugin will fail. You can set strict_permissions to
              False in the inventory config file which will allow 403 errors to be gracefully skipped.
          type: bool
          default: True
s�

# Minimal example using environment vars or instance role credentials
# Fetch all hosts in us-east-1, the hostname is the public DNS if it exists, otherwise the private IP address
plugin: aws_ec2
regions:
  - us-east-1

# Example using filters, ignoring permission errors, and specifying the hostname precedence
plugin: aws_ec2
boto_profile: aws_profile
regions: # populate inventory with instances in these regions
  - us-east-1
  - us-east-2
filters:
  # all instances with their `Environment` tag set to `dev`
  tag:Environment: dev
  # all dev and QA hosts
  tag:Environment:
    - dev
    - qa
  instance.group-id: sg-xxxxxxxx
# ignores 403 errors rather than failing
strict_permissions: False
# note: I(hostnames) sets the inventory_hostname. To modify ansible_host without modifying
# inventory_hostname use compose (see example below).
hostnames:
  - tag:Name=Tag1,Name=Tag2  # return specific hosts only
  - tag:CustomDNSName
  - dns-name
  - private-ip-address

# Example using constructed features to create groups and set ansible_host
plugin: aws_ec2
regions:
  - us-east-1
  - us-west-1
# keyed_groups may be used to create custom groups
strict: False
keyed_groups:
  # add e.g. x86_64 hosts to an arch_x86_64 group
  - prefix: arch
    key: 'architecture'
  # add hosts to tag_Name_Value groups for each Name/Value tag pair
  - prefix: tag
    key: tags
  # add hosts to e.g. instance_type_z3_tiny
  - prefix: instance_type
    key: instance_type
  # create security_groups_sg_abcd1234 group for each SG
  - key: 'security_groups|json_query("[].group_id")'
    prefix: 'security_groups'
  # create a group for each value of the Application tag
  - key: tags.Application
    separator: ''
  # create a group per region e.g. aws_region_us_east_2
  - key: placement.region
    prefix: aws_region
# set individual variables with compose
compose:
  # use the private IP address to connect to the host
  # (note: this does not modify inventory_hostname, which is set via I(hostnames))
  ansible_host: private_ip_address
(tAnsibleError(t	to_nativetto_text(t!ansible_dict_to_boto3_filter_listtboto3_tag_list_to_ansible_dict(tcamel_dict_to_snake_dict(tBaseInventoryPlugint
Constructablet	Cacheabletto_safe_group_name(tdisplay(tDisplayNs=The ec2 dynamic inventory plugin requires boto3 and botocore.tGroupstGroupIdsgroup-idt	GroupNames
group-nametOwnerIds.network-interface.attachment.instance-owner-idsowner-idtRequesterIdsrequester-idt
ReservationIdsreservation-idt	PlacementtAffinitytaffinitytArchitecturetarchitecturetAvailabilityZonesavailability-zonetBlockDeviceMappingstEbst
AttachTimes block-device-mapping.attach-timetDeleteOnTerminations*block-device-mapping.delete-on-terminationt
DeviceNames block-device-mapping.device-nametStatussblock-device-mapping.statustVolumeIdsblock-device-mapping.volume-idtClientTokensclient-tokent
PublicDnsNamesdns-nametHostIdshost-idt
Hypervisort
hypervisortIamInstanceProfiletArnsiam-instance-profile.arntImageIdsimage-idt
InstanceIdsinstance-idtInstanceLifecyclesinstance-lifecycletStatetCodesinstance-state-codetNamesinstance-state-nametInstanceTypes
instance-typetSecurityGroupssinstance.group-idsinstance.group-nametPublicIpAddresss
ip-addresstKernelIds	kernel-idtKeyNameskey-nametAmiLaunchIndexslaunch-indext
LaunchTimeslaunch-timet
Monitoringsmonitoring-statetNetworkInterfacestPrivateIpAddresss.network-interface.addresses.private-ip-addresstPrivateIpAddressestPrimarys#network-interface.addresses.primarytAssociationtPublicIps1network-interface.addresses.association.public-ipt	IpOwnerIds3network-interface.addresses.association.ip-owner-ids'network-interface.association.public-ips)network-interface.association.ip-owner-idtElasticGpuAssociationstElasticGpuIds+network-interface.association.allocation-idtElasticGpuAssociationIds,network-interface.association.association-idt
AttachmenttAttachmentIds*network-interface.attachment.attachment-ids(network-interface.attachment.instance-idtDeviceIndexs)network-interface.attachment.device-indexs#network-interface.attachment.statuss(network-interface.attachment.attach-times2network-interface.attachment.delete-on-terminations#network-interface.availability-zonetDescriptionsnetwork-interface.descriptionsnetwork-interface.group-idsnetwork-interface.group-namet
Ipv6AddressestIpv6Addresss-network-interface.ipv6-addresses.ipv6-addresst
MacAddresssnetwork-interface.mac-addresstNetworkInterfaceIds&network-interface.network-interface-idsnetwork-interface.owner-idtPrivateDnsNames"network-interface.private-dns-names#network-interface.requester-managedsnetwork-interface.statustSourceDestChecks#network-interface.source-dest-checktSubnetIdsnetwork-interface.subnet-idtVpcIdsnetwork-interface.vpc-idsplacement-group-nametPlatformtplatformsprivate-dns-namesprivate-ip-addresstProductCodest
ProductCodeIdsproduct-codetProductCodeTypesproduct-code.typet	RamdiskIds
ramdisk-idtStateTransitionReasontreasontRootDeviceNamesroot-device-nametRootDeviceTypesroot-device-typessource-dest-checktSpotInstanceRequestIdsspot-instance-request-idtStateReasonsstate-reason-codetMessagesstate-reason-messages	subnet-idtTagsttagstag-keys	tag-valuetTenancyttenancytVirtualizationTypesvirtualization-typesvpc-idtInventoryModulecB`s�eZdZd�Zd�Zd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zed�ZRS(taws_ec2cC`sDtt|�j�d|_d|_d|_d|_d|_dS(Ntaws_ec2_(	tsuperR_t__init__tgroup_prefixtNonetboto_profiletaws_secret_access_keytaws_access_key_idtaws_security_token(tself((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyRc�s				cC`s�|dkrdSg}t|t�s4t|t�rpxH|D].}|j||�}|r;|j|�q;q;Wn|j|�}tt|t�t|t�g�}|r�t|�dkr�|dS|S(s�
            :param obj: A list or dict of instance attributes
            :param attr: A key
            :return The value(s) found via the attr
        Nii(	Ret
isinstancetlistttuplet_compile_valuestappendtgettanytlen(Rjtobjtattrttemp_objteachtvaluethas_indexes((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyRn	s
$cC`s�tttj��ttj���}||krMtd||f��n|tkrft|}n
t|}|}x |D]}|j||�}q}W|S(s�
            :param filter_name: The filter
            :param instance: instance dict returned by boto3 ec2 describe_instances()
        s7Invalid filter '%s' provided; filter must be one of %s.(tsortedRlt!instance_data_filter_to_boto_attrtkeyst!instance_meta_filter_to_boto_attrRRn(Rjtfilter_nametinstancetallowed_filterstboto_attr_listtinstance_valuet	attribute((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt_get_boto_attr_chain"s(	


cC`s^i}xQd|jfd|jfd|jffD]%}|dr1|d||d<q1q1W|S(sE
            :return A dictionary of boto client credentials
        RhRgtaws_session_tokenii(RhRgRi(Rjtboto_paramst
credential((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt_get_credentials5s
s	us-east-1cC`s�y+tjjd|j�jd||�}Wn�tjjtjjfk
r�}|jr�y(tjjd|j�jd|�}Wq�tjjtjjfk
r�}t	dt
|���q�Xq�t	dt
|���nX|S(Ntprofile_nametec2s"Insufficient credentials found: %s(tboto3tsessiontSessionRftclienttbotocoret
exceptionstProfileNotFoundtPartialCredentialsErrorRR(Rjtcredentialstregiont
connectionte((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt_get_connectionBs+!	(!c	c`s�|j�}|swyH|j|�}|j�}g|jdg�D]}|d^qC}Wqwtjjk
rsqwXn|s�tj�}|j	d�}n|s�t
d��nx+|D]#}|j||�}||fVq�WdS(s�
            :param regions: A list of regions to create a boto3 client

            Generator that yields a boto3 client and the region
        tRegionst
RegionNameR�seUnable to get regions list from available methods, you must specify the "regions" option to continue.N(R�R�tdescribe_regionsRpR�R�t
NoRegionErrorR�R�tget_available_regionsR(	RjtregionsR�R�tresptxR�R�R�((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt_boto3_connOs -
c
C`s�g}xe|j|�D]T\}}y�tg|D]}|ddk^q/�sx|jidd6ddddgd6�n|jd�}|jd	|�j�jd
�}	g}
x$|	D]}|
j|jd��q�WWn�tj	j
k
r.}|jdd
dkr|rg}
q]tdt
|���n/tj	jk
r\}tdt
|���nX|j|
�qWt|dd��S(s,
           :param regions: a list of regions in which to describe instances
           :param filters: a list of boto3 filter dicionaries
           :param strict_permissions: a boolean determining whether to fail or ignore 403 error codes
           :return A list of instance dictionaries
        R.sinstance-state-nametrunningtpendingtstoppingtstoppedtValuestdescribe_instancestFilterstReservationst	InstancestResponseMetadatatHTTPStatusCodei�s Failed to describe instances: %stkeycS`s|dS(NR*((R�((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt<lambda>�s(R�RqRot
get_paginatortpaginatetbuild_full_resultRptextendR�R�tClientErrortresponseRRt
BotoCoreErrorRy(
RjR�tfilterststrict_permissionst
all_instancesR�R�tft	paginatortreservationst	instancestrR�((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt_get_instances_by_regionos$)*!
	cC`s�|jdd�d}d|kr4|jd�}n	|g}t|jdg��}x~|D]v}d|kr�|jd�\}}|j|�|kr�t|�dt|�Sq\|j|�}|r\t|�Sq\WdS(Nstag:it,RZt=t_(tsplitRRpRRe(Rjt
preferenceR~t
tag_hostnamesttagstvttag_namet	tag_value((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt_get_tag_hostname�s	
cC`s�|sddg}nd}xi|D]a}d|krg|jd�sRtd��n|j||�}n|j||�}|r"Pq"q"W|r�dt|�kr�tt|��St|�SndS(s�
            :param instance: an instance dict returned by boto3 ec2 describe_instances()
            :param hostnames: a list of hostname destination variables in order of preference
            :return the preferred identifer for the host
        sdns-namesprivate-dns-nameR[stag:s8To name a host by tags name_value, use 'tag:name=value'.t:N(Ret
startswithRR�R�RR(RjR~t	hostnamesthostnameR�((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt
_get_hostname�s
cC`si|j|||�d6S(sE
            :param regions: a list of regions to query
            :param filters: a list of boto3 filter dictionaries
            :param hostnames: a list of hostname destination variables in order of preference
            :param strict_permissions: a boolean determining whether to fail or ignore 403 error codes
        R`(R�(RjR�R�R�((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt_query�scC`sXxQ|D]I}|jj|�|jd||d|d|�|jjd|�qWdS(NthoststgroupR�tall(t	inventoryt	add_groupt
_add_hostst	add_child(RjtgroupsR�R�((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt	_populate�s
 c	C`s<x5|D]-}|j||�}t|ddg�}t|jdg��|d<|ddd |dd<|svqn|jj|d|�x0|j�D]"\}}|jj|||�q�W|jd	�}|j	|jd
�||d	|�|j
|jd�||d	|�|j|jd�||d	|�qWd
S(s�
            :param hosts: a list of hosts to be added to a group
            :param group: the name of the group to which the hosts belong
            :param hostnames: a list of hostname destination variables in order of preference
        tignore_listRZR�t	placementtavailability_zonei����R�R�tstricttcomposeR�tkeyed_groupsN(R�RRRpR�tadd_hosttitemstset_variablet
get_optiont_set_composite_varst_add_host_to_composed_groupst_add_host_to_keyed_groups(	RjR�R�R�thostR�thostvarthostvalR�((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyR��s
""cC`s�|jd�|_|jd�|_|jd�|_|jd�|_|jr�|joa|jr�tjj�}|j�dk	r�|j�j
|_|j�j|_|j�j|_q�n|jr�|jo�|jr�t
d��ndS(sO
            :param config_data: contents of the inventory config file
        RfRhRgRis�Insufficient boto credentials found. Please provide them in your inventory configuration file or set them as environment variables.N(R�RfRhRgRiR�R�tget_sessiontget_credentialsRet
access_keyt
secret_keyttokenR(RjR�((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt_set_credentials�scC`s?tt|�j|�r.|jd�r.tSntjd�tS(s�
            :param loader: an ansible.parsing.dataloader.DataLoader object
            :param path: the path to the inventory config file
            :return the contents of the config file
        saws_ec2.ymlsaws_ec2.yamlsHaws_ec2 inventory filename must end with 'aws_ec2.yml' or 'aws_ec2.yaml'(saws_ec2.ymlsaws_ec2.yaml(RbR_tverify_filetendswithtTrueR
tdebugtFalse(Rjtpath((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyR��s

c
C`sHtt|�j|||�|j|�}|j�|jd�}t|jd��}|jd�}|jd�}	|j|�}
|r�|jd�}nt}|r�y|j	j
|
�}Wq�tk
r�t}q�Xn|s�|r|j
|||	�}n|j||�|s.|rD|jd�rD|j	j|
|�ndS(NR�R�R�R�tcache(RbR_tparset_read_config_dataR�R�Rt
get_cache_keyR�R�RptKeyErrorR�R�R�tset(
RjR�tloaderR�R�tconfig_dataR�R�R�R�t	cache_keytcache_needs_updatetresults((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyR�s*



(t__name__t
__module__tNAMERcRnR�R�R�R�R�R�R�R�R�R�R�R�R�R�(((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyR_�s 				

	 							"		(RR(RR(R(R(R(R(RR(R(RR(RRR(RRR(RR(RRR (RRR!(R"(R#(RR$(R%(R'R((R)(s
InstanceId(R+(R,R-(R,sName(sInstanceType(R0R(R0R(R1(R2(R3(R4(R5(R6R,(R7R8(R7R9R:(R7R9R;R<(R7R9R;R=(R7R;R<(R7R;R=(R>R?(R>R@(R7RARB(s
InstanceId(R7RARC(R7RAR (R7RAR(R7RAR(RR(R7RD(R7RR(R7RR(R7RERF(R7RG(R7RH(R7R(R7RI(R7R;R=(R7R (R7RJ(R7RK(R7RL(RR(RM(RI(R8(RORP(RORQ(RR(RS(RU(RV(RJ(RW(RXR-(RXRY(RK(sTags(sTags(sTags(RR\(R^(RL( t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONtEXAMPLEStansible.errorsRtansible.module_utils._textRRtansible.module_utils.ec2RRRtansible.plugins.inventoryR	R
RRt__main__R
tImportErrortansible.utils.displayRR�R�R|RzR_(((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_ec2.pyt<module>s�CA"






Anon7 - 2022
AnonSec Team