AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.144.85.61
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/azure_rm.pyo
�
��\c@`sddlmZmZmZeZdZdZddlZddl	Z	ddl
Z
ddlZyddlm
Z
mZWn'ek
r�ddl
m
Z
mZnXddlmZddlmZddlmZmZmZdd	lmZdd
lmZddlmZmZddlm Z dd
l!m"Z"ddl#m$Z$ddl%m&Z&m'Z'm(Z(ddl)m*Z*ddl+m,Z,de*fd��YZ-edddddg�Z.deefd��YZ/de0fd��YZ1de0fd��YZ2de0fd ��YZ3dS(!i(tabsolute_importtdivisiontprint_functionsN

    name: azure_rm
    plugin_type: inventory
    short_description: Azure Resource Manager inventory plugin
    extends_documentation_fragment:
      - azure
    description:
        - Query VM details from Azure Resource Manager
        - Requires a YAML configuration file whose name ends with 'azure_rm.(yml|yaml)'
        - By default, sets C(ansible_host) to the first public IP address found (preferring the primary NIC). If no
          public IPs are found, the first private IP (also preferring the primary NIC). The default may be overridden
          via C(hostvar_expressions); see examples.
    options:
        plugin:
            description: marks this as an instance of the 'azure_rm' plugin
            required: true
            choices: ['azure_rm']
        include_vm_resource_groups:
            description: A list of resource group names to search for virtual machines. '\*' will include all resource
                groups in the subscription.
            default: ['*']
        include_vmss_resource_groups:
            description: A list of resource group names to search for virtual machine scale sets (VMSSs). '\*' will
                include all resource groups in the subscription.
            default: []
        fail_on_template_errors:
            description: When false, template failures during group and filter processing are silently ignored (eg,
                if a filter or group expression refers to an undefined host variable)
            choices: [True, False]
            default: True
        keyed_groups:
            description: Creates groups based on the value of a host variable. Requires a list of dictionaries,
                defining C(key) (the source dictionary-typed variable), C(prefix) (the prefix to use for the new group
                name), and optionally C(separator) (which defaults to C(_))
        conditional_groups:
            description: A mapping of group names to Jinja2 expressions. When the mapped expression is true, the host
                is added to the named group.
        hostvar_expressions:
            description: A mapping of hostvar names to Jinja2 expressions. The value for each host is the result of the
                Jinja2 expression (which may refer to any of the host's existing variables at the time this inventory
                plugin runs).
        exclude_host_filters:
            description: Excludes hosts from the inventory with a list of Jinja2 conditional expressions. Each
                expression in the list is evaluated for each host; when the expression is true, the host is excluded
                from the inventory.
            default: []
        batch_fetch:
            description: To improve performance, results are fetched using an unsupported batch API. Disabling
                C(batch_fetch) uses a much slower serial fetch, resulting in many more round-trips. Generally only
                useful for troubleshooting.
            default: true
        default_host_filters:
            description: A default set of filters that is applied in addition to the conditions in
                C(exclude_host_filters) to exclude powered-off and not-fully-provisioned hosts. Set this to a different
                value or empty list if you need to include hosts in these states.
            default: ['powerstate != "running"', 'provisioning_state != "succeeded"']
s}
# The following host variables are always available:
# public_ipv4_addresses: all public IP addresses, with the primary IP config from the primary NIC first
# public_dns_hostnames: all public DNS hostnames, with the primary IP config from the primary NIC first
# private_ipv4_addresses: all private IP addressses, with the primary IP config from the primary NIC first
# id: the VM's Azure resource ID, eg /subscriptions/00000000-0000-0000-1111-1111aaaabb/resourceGroups/my_rg/providers/Microsoft.Compute/virtualMachines/my_vm
# location: the VM's Azure location, eg 'westus', 'eastus'
# name: the VM's resource name, eg 'myvm'
# powerstate: the VM's current power state, eg: 'running', 'stopped', 'deallocated'
# provisioning_state: the VM's current provisioning state, eg: 'succeeded'
# tags: dictionary of the VM's defined tag values
# resource_type: the VM's resource type, eg: 'Microsoft.Compute/virtualMachine', 'Microsoft.Compute/virtualMachineScaleSets/virtualMachines'
# vmid: the VM's internal SMBIOS ID, eg: '36bca69d-c365-4584-8c06-a62f4a1dc5d2'
# vmss: if the VM is a member of a scaleset (vmss), a dictionary including the id and name of the parent scaleset


# sample 'myazuresub.azure_rm.yaml'

# required for all azure_rm inventory plugin configs
plugin: azure_rm

# forces this plugin to use a CLI auth session instead of the automatic auth source selection (eg, prevents the
# presence of 'ANSIBLE_AZURE_RM_X' environment variables from overriding CLI auth)
auth_source: cli

# fetches VMs from an explicit list of resource groups instead of default all (- '*')
include_vm_resource_groups:
- myrg1
- myrg2

# fetches VMs from VMSSs in all resource groups (defaults to no VMSS fetch)
include_vmss_resource_groups:
- '*'

# places a host in the named group if the associated condition evaluates to true
conditional_groups:
  # since this will be true for every host, every host sourced from this inventory plugin config will be in the
  # group 'all_the_hosts'
  all_the_hosts: true
  # if the VM's "name" variable contains "dbserver", it will be placed in the 'db_hosts' group
  db_hosts: "'dbserver' in name"

# adds variables to each host found by this inventory plugin, whose values are the result of the associated expression
hostvar_expressions:
  my_host_var:
  # A statically-valued expression has to be both single and double-quoted, or use escaped quotes, since the outer
  # layer of quotes will be consumed by YAML. Without the second set of quotes, it interprets 'staticvalue' as a
  # variable instead of a string literal.
  some_statically_valued_var: "'staticvalue'"
  # overrides the default ansible_host value with a custom Jinja2 expression, in this case, the first DNS hostname, or
  # if none are found, the first public IP address.
  ansible_host: (public_dns_hostnames + public_ipv4_addresses) | first

# places hosts in dynamically-created groups based on a variable value.
keyed_groups:
# places each host in a group named 'tag_(tag name)_(tag value)' for each tag on a VM.
- prefix: tag
  key: tags
# places each host in a group named 'azure_loc_(location name)', depending on the VM's location
- prefix: azure_loc
  key: location
# places host in a group named 'some_tag_X' using the value of the 'sometag' tag on a VM as X, and defaulting to the
# value 'none' (eg, the group 'some_tag_none') if the 'sometag' tag is not defined for a VM.
- prefix: some_tag
  key: tags.sometag | default('none')

# excludes a host from the inventory when any of these expressions is true, can refer to any vars defined on the host
exclude_host_filters:
# excludes hosts in the eastus region
- location in ['eastus']
# excludes hosts that are powered off
- powerstate != 'running'
N(tQueuetEmpty(t
namedtuple(trelease(tBaseInventoryPlugint
Constructablet	Cacheable(t	iteritems(tAzureRMAuth(tAnsibleParserErrortAnsibleError(tboolean(t	to_native(tchain(t
ServiceClientt
SerializertDeserializer(tAzureConfiguration(t
ARMPollingtAzureRMRestConfigurationcB`seZdd�ZRS(cC`s�|dkrtd��n|dkr6td��n|sEd}ntt|�j|�|jdjtj��||_	||_
dS(Ns)Parameter 'credentials' must not be None.s-Parameter 'subscription_id' must not be None.shttps://management.azure.comsansible-dynamic-inventory/{0}(tNonet
ValueErrortsuperRt__init__tadd_user_agenttformatRt__version__tcredentialstsubscription_id(tselfRRtbase_url((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR�s		N(t__name__t
__module__RR(((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR�st	UrlActionturltapi_versionthandlerthandler_argstInventoryModulecB`s�eZdZd�Zd�Zed�Zd�Zdd�Z	dd�Z
dd�Zd	�Zd
�Z
d�Zd�Zdd
�Zd�Zd�Zd�Zd�ZRS(tazure_rmcC`s�tt|�j�t�|_t�|_g|_d|_	d|_
d|_idd6|_t
�|_d|_t|_dS(Ns
2017-03-30s
2015-06-15sapplication/json; charset=utf-8sContent-Type(RR)RRt_serializerRt
_deserializert_hostsRt_filterst_compute_api_versiont_network_api_versiont_default_header_parametersRt_request_queuet
azure_authtFalset_batch_fetch(R ((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR�s					cC`s5tt|�j|�r1tjd|�r1tSntS(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
        s.{0,}azure_rm\.y(a)?ml$(RR)tverify_filetretmatchtTrueR4(R tpath((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR6�scC`s�tt|�j|||�|j|�|jd�|_|jd�|jd�|_y|j�|j�Wnt	k
r�}�nXdS(Ntbatch_fetchtexclude_host_filterstdefault_host_filters(
RR)tparset_read_config_datat
get_optionR5R.t_credential_setupt
_get_hostst	Exception(R t	inventorytloaderR:tcachetex((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR>�s

cC`std|jd�d|jd�d|jd�d|jd�d|jd�d|jd�d|jd�d|jd�d	|jd	�d
|jd
�d|jd�d|jd��}t|�|_t|jj|jj|jjjj	�|_
t|j
j|j
�|_
dS(
Ntauth_sourcetprofileRt	client_idtsecretttenanttad_usertpasswordtcloud_environmenttcert_validation_modetapi_profiletadfs_authority_url(tdictR@RR3Rtazure_credentialsRt_cloud_environmentt	endpointstresource_managert
_clientconfigRRt_client(R tauth_options((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRA�s"c
C`s>|si}n|jjtd|d|d|d|��dS(NR%R&R'R((R2t
put_nowaitR$(R R%R&R'R(((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyt_enqueue_gets	t*cC`sf|s|dkrd}nd}|jd|jjd|�}|jd|d|jd|j�dS(	NR]sK/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachiness_/subscriptions/{subscriptionId}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachinestsubscriptionIdtrgR%R&R'(RRXRR\R/t_on_vm_page_response(R R_R%((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyt_enqueue_vm_list
s
	cC`sf|s|dkrd}nd}|jd|jjd|�}|jd|d|jd|j�dS(	NR]sS/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSetssg/subscriptions/{subscriptionId}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachineScaleSetsR^R_R%R&R'(RRXRR\R/t_on_vmss_page_response(R R_R%((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyt_enqueue_vmss_lists
	c	C`s�x$|jd�D]}|j|�qWx$|jd�D]}|j|�q7W|jrd|j�n
|j�t|jd��}|jd�}|jd�}|jd�}x|jD]}|j|�}|j	||j
�r�q�n|jj|�|jj
|dtt|j
d|j
d	�d��x3t|j
�D]"\}	}
|jj
||	|
�q@W|j||j
|d
|�|j||j
|d
|�|j||j
|d
|�q�WdS(Ntinclude_vm_resource_groupstinclude_vmss_resource_groupstfail_on_template_errorsthostvar_expressionstconditional_groupstkeyed_groupstansible_hosttpublic_ipv4_addressestprivate_ipv4_addresseststrict(R@RaRcR5t_process_queue_batcht_process_queue_serialRR-t
_get_hostnamet_filter_hostthostvarsRDtadd_hosttset_variabletnextRRR
t_set_composite_varst_add_host_to_composed_groupst_add_host_to_keyed_groups(R tvm_rgtvmss_rgtconstructable_config_stricttconstructable_config_composetconstructable_config_groupst!constructable_config_keyed_groupsthtinventory_hostnametktv((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRBs.	

'cC`s�|jj|�x�|jD]�}dj|�}y t|jj|��rNtSWqtk
r�}t|jd��rt	dj||t
|����qqqXqWtS(Ns4{{% if {0} %}} True {{% else %}} False {{% endif %}}Rfs9Error evaluating filter condition '{0}' for host {1}: {2}(ttemplartset_available_variablesR.RRttemplateR9RCR@RRR4(R R�Rrt	conditiontconditionalte((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRq?s$cC`s|jS(N(tdefault_inventory_hostname(R thost((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRpOscC`scyKxDtrI|jj�}|j|j|j�}|j||j�qWWntk
r^nXdS(N(	R9R2t
get_nowaittsend_requestR%R&R'R(R(R titemtresp((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRoSs	
cC`s�|jd�}|r:|jd|d|jd|j�nd|kr}x4|dD]%}|jjt||d|��qQWndS(NtnextLinkR%R&R'tvaluetvmss(tgetR\R/R`R-tappendt	AzureHost(R tresponseR�t	next_linkR((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR`\s%cC`s�|jd�}|r:|jd|d|jd|j�nxV|dD]J}dj|d�}|jd|d|jd|jdtd	|��qEWdS(
NR�R%R&R'R�s{0}/virtualMachinestidR(R�(R�R\R/RbRR`RS(R R�R�R�R%((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRbgs%cC`s�x�tr�g}d}t�}y�x�|dkr�|jj�}ttj��}i|jd6}|jj	|j
|�}|jtddd|j
d|��|||<|d7}q$WWntk
r�nX|s�Pn|j
|�}d}	d	|kr�d	}	n!d
|krd
}	ntd��x�t||	�D]p\}
}|j	d�}|d}
||
}|d
kr�tdj||j
���n|j|d|j�q1WqWdS(Niidsapi-versiont
httpMethodtGETR%tnameit	responsesR�s:didn't find expected key responses/value in batch responsethttpStatusCodei�s6a batched request failed with status code {0}, url {1}tcontent(R9RSR2R�tstrtuuidtuuid4R&RYR�R%R�Rt_send_batchRR
t	enumerateRR'R((R tbatch_requeststbatch_item_indextbatch_response_handlersR�R�tquery_parameterstreqt
batch_resptkey_nametidxtrtstatus_codet
returned_nametresult((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRnus>		%

		

c
`s�d}idd6}td|�}�jj|d�}ittj��d6}|j�j��jj	||�}�jj
|||�}tdd�}	|	jd	�jd
|d�fd��|	j
�|	j�S(
Ns/batchs
2015-11-01sapi-versiontrequeststobjectsx-ms-client-request-idttimeoutitclienttinitial_responsetdeserialization_callbackc`s�jd|�S(NR�(R,(R�(R (sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyt<lambda>�s(RSR+tbodyR�R�R�tupdateR1RYtposttsendRt
initializetruntresource(
R tbatched_requestsR%R�tbody_objtbody_contenttheadertrequestR�tpoller((R sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR��s

cC`s`i|d6}|jj||�}|jj||jdt�}|j�|j}tj|�S(Nsapi-versiontstream(	RYR�R�R1R4traise_for_statusR�tjsontloads(R R%R&R�R�R�R�((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR��s

	N(R"R#tNAMERR6R9R>RARR\RaRcRBRqRpRoR`RbRnR�R�(((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR)�s"						#						)	R�cB`sGeZejd�Zdd�Zed��Zd�Z	e
d�ZRS(s^PowerState/(?P<powerstate>.+)$cC`s-||_||_||_d|_d|_g|_dj|dtj	|d�j
�dd!�|_i|_|j
ddj|d�d	|jjd
|j�|ddd
}xp|D]h}|jdi�jdt|�dk�}|j
d|dd	|jjd
|jdtd|��q�WdS(Ntunknowns{0}_{1}R�R�iiR%s{0}/instanceViewR&R't
propertiestnetworkProfiletnetworkInterfacestprimaryiR(t
is_primary(t_inventory_clientt	_vm_modelt_vmssRt
_instanceviewt_powerstatetnicsRthashlibtsha1t	hexdigestR�t	_hostvarsR\R/t_on_instanceview_responseR�tlenR0t_on_nic_responseRS(R tvm_modeltinventory_clientR�tnic_refstnicR�((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR�s"						3	

*	cC`s|jikr|jStdgdgdgd|jdd|jdd|jdd|jd|jd	d
j�d|jjdi�d|jjd
d�d|jd	dd|jr�td|jdd|jd�ni�}xt|jdd�dt	�D]�}x�t|j
d	ddd�dt	�D]�}|d	jd�}|rd|dj|�n|d	jdi�jd�}|r1|j|}|dj|j
d	jdd��|j
d	jdi�jd�}|r�|dj|�q�q1q1WqW||_|jS(NRktpublic_dns_hostnamesRlR�tlocationR�t
powerstatetprovisioning_stateR�tprovisioningStatettagst
resource_typettypeR�tvmidtvmIdR�tkeycS`s|jS(N(R�(tn((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR��streversetipConfigurationscS`s|ddS(NR�R�((ti((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR��stprivateIPAddresstpublicIPAddresst	ipAddresstdnsSettingstfqdn(R�RSR�R�tlowerR�R�tsortedR�R9t
_nic_modelR�t
public_ipst
_pip_modelR(R tnew_hostvarsR�tipct
private_iptpip_idtpiptpip_fqdn((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRr�s:


	5%-
$"	c`s;|�_t�fd�|jdg�D�d��_dS(Nc3`sT|]J}�jj|jdd��r�jj|jdd��jd�VqdS(tcodetR�N(t_powerstate_regexR8R�tgroup(t.0ts(R (sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pys	<genexpr>ststatusesR�(R�RuR�R�(R tvm_instanceview_model((R sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR�s	cC`sJ|jd�dkrFtd|d|jd|�}|jj|�ndS(NR�s#Microsoft.Network/networkInterfacest	nic_modelR�R�(R�tAzureNicR�R�R�(R RR�R�((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR�sN(R"R#R7tcompileRRRtpropertyRrR�R4R�(((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR��s
*	RcB`seZed�Zd�ZRS(cC`s�||_||_||_i|_x^|ddD]N}|djd�}|r3|jjd|dd|jjd|j�q3q3WdS(NR�R�R�R%R�R&R'(R�R�R�R�R�R\R0t_on_pip_response(R RR�R�R�R�((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRs				cC`st|�|j|d<dS(NR�(tAzurePipR�(R t	pip_model((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR
$s(R"R#R4RR
(((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyRsRcB`seZd�ZRS(cC`s
||_dS(N(R�(R R((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR)s(R"R#R(((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyR(s(4t
__future__RRRR�t
__metaclass__t
DOCUMENTATIONtEXAMPLESR�R�R7R�tqueueRRtImportErrortcollectionsRtansibleRtansible.plugins.inventoryRRR	tansible.module_utils.sixR
t$ansible.module_utils.azure_rm_commonRtansible.errorsRR
t)ansible.module_utils.parsing.convert_boolRtansible.module_utils._textRt	itertoolsRtmsrestRRRtmsrestazureRtmsrestazure.polling.arm_pollingRRR$R)R�R�RR(((sF/usr/lib/python2.7/site-packages/ansible/plugins/inventory/azure_rm.pyt<module>s<:J
�S

Anon7 - 2022
AnonSec Team