AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 13.58.193.140
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/tower.pyo
�
��\c@`sddlmZmZmZeZdZdZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZddlmZddlmZdd	lmZydd
lmZWn!ek
r�dd
lmZnXdefd��YZdS(
i(tabsolute_importtdivisiontprint_functions�
    name: tower
    plugin_type: inventory
    author:
      - Matthew Jones (@matburt)
      - Yunfan Zhang (@YunfanZhang42)
    short_description: Ansible dynamic inventory plugin for Ansible Tower.
    version_added: "2.7"
    description:
        - Reads inventories from Ansible Tower.
        - Supports reading configuration from both YAML config file and environment variables.
        - If reading from the YAML file, the file name must end with tower.(yml|yaml) or tower_inventory.(yml|yaml),
          the path in the command would be /path/to/tower_inventory.(yml|yaml). If some arguments in the config file
          are missing, this plugin will try to fill in missing arguments by reading from environment variables.
        - If reading configurations from environment variables, the path in the command must be @tower_inventory.
    options:
        plugin:
            description: the name of this plugin, it should always be set to 'tower'
                for this plugin to recognize it as it's own.
            env:
                - name: ANSIBLE_INVENTORY_ENABLED
            required: True
            choices: ['tower']
        host:
            description: The network address of your Ansible Tower host.
            type: string
            env:
                - name: TOWER_HOST
            required: True
        username:
            description: The user that you plan to use to access inventories on Ansible Tower.
            type: string
            env:
                - name: TOWER_USERNAME
            required: True
        password:
            description: The password for your Ansible Tower user.
            type: string
            env:
                - name: TOWER_PASSWORD
            required: True
        inventory_id:
            description: The ID of the Ansible Tower inventory that you wish to import.
            type: string
            env:
                - name: TOWER_INVENTORY
            required: True
        verify_ssl:
            description: Specify whether Ansible should verify the SSL certificate of Ansible Tower host.
            type: bool
            default: True
            env:
                - name: TOWER_VERIFY_SSL
            required: False
sA
# Before you execute the following commands, you should make sure this file is in your plugin path,
# and you enabled this plugin.

# Example for using tower_inventory.yml file

plugin: tower
host: your_ansible_tower_server_network_address
username: your_ansible_tower_username
password: your_ansible_tower_password
inventory_id: the_ID_of_targeted_ansible_tower_inventory
# Then you can run the following command.
# If some of the arguments are missing, Ansible will attempt to read them from environment variables.
# ansible-inventory -i /path/to/tower_inventory.yml --list

# Example for reading from environment variables:

# Set environment variables:
# export TOWER_HOST=YOUR_TOWER_HOST_ADDRESS
# export TOWER_USERNAME=YOUR_TOWER_USERNAME
# export TOWER_PASSWORD=YOUR_TOWER_PASSWORD
# export TOWER_INVENTORY=THE_ID_OF_TARGETED_INVENTORY
# Read the inventory specified in TOWER_INVENTORY from Ansible Tower, and list them.
# The inventory path must always be @tower_inventory if you are reading all settings from environment variables.
# ansible-inventory -i @tower_inventory --list
N(tsix(tRequestturllib_errortConnectionErrortsocketthttplib(t	to_native(tAnsibleParserError(tBaseInventoryPlugin(turljointInventoryModulecB`s5eZdZeZed�Zd�Zed�ZRS(ttowerc	C`sitjd|�s'djd|�}n|jdd�}djd|�}t||�}td|d	|d
td|�}y|j|�}	Wn�tt	j
tjt
jfk
r}
djd
|
�}tt|
dd��r�|djd|
j��7}ntt|���nXytj|	j��SWn7ttfk
rd}
ttdjd
|
����nXdS(Ns(?:http|https)://shttps://{tower_host}t
tower_hostt/tsA/api/v2/inventories/{inv_id}/script/?hostvars=1&towervars=1&all=1tinv_idturl_usernameturl_passwordtforce_basic_authtvalidate_certss'Connection to remote host failed: {err}terrtreads with message: {err_msg}terr_msgs%Failed to parse json from host: {err}(tretmatchtformattreplaceRRtTruetgetRRtURLErrorRterrorRt
HTTPExceptiontcallabletgetattrtNoneRR
R	tjsontloadst
ValueErrort	TypeError(tselfRt
tower_usert
tower_passt	inventoryt
verify_ssltinventory_idt
inventory_urltrequest_handlertresponsetet	error_msg((sC/usr/lib/python2.7/site-packages/ansible/plugins/inventory/tower.pytread_tower_inventoryqs(	$cC`sI|jd�rt|_tStt|�j|�rA|jd�StSdS(Ns@tower_inventorystower_inventory.ymlstower_inventory.yamls	tower.ymls
tower.yaml(stower_inventory.ymlstower_inventory.yamls	tower.ymls
tower.yaml(tendswithRtno_config_file_suppliedtsuperR
tverify_filetFalse(R*tpath((sC/usr/lib/python2.7/site-packages/ansible/plugins/inventory/tower.pyR9�s	
c
	C`s4tt|�j|||�|jrHtjj|�rH|j|�n|j|j	d�|j	d�|j	d�|j	d�d|j	d��}x-|D]%}|dkr�|j
j|�q�q�W|dd}xctj
|�D]R\}}|j
j|�x3tj
|�D]"\}	}
|j
j||	|
�q
Wq�Wx�tj
|�D]�\}}|dkr�|dkr�x-|jd	g�D]}|j
j||�q~Wx0|jd
g�D]}|j
j||�q�Wn|dkrGxBtj
|jdi��D]"\}	}
|j
j||	|
�q�WqGqGW|j
j�dS(NthosttusernametpasswordR/R.t_metathostvarstallthoststchildrentvars(R8R
tparseR7tosR;tisfilet_read_config_dataR5t
get_optionR-t	add_groupRt	iteritemstadd_hosttset_variableRt	add_childtreconcile_inventory(
R*R-tloaderR;tcachet
group_namet	all_hostst	host_namet	host_varstvar_namet	var_valuet
group_contenttchild_group_name((sC/usr/lib/python2.7/site-packages/ansible/plugins/inventory/tower.pyRE�s4
(!(	t__name__t
__module__tNAMER:R7RR5R9RE(((sC/usr/lib/python2.7/site-packages/ansible/plugins/inventory/tower.pyR
ks
		(t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONtEXAMPLESRRFR&tansible.module_utilsRtansible.module_utils.urlsRRRRRtansible.module_utils._textR	tansible.errorsR
tansible.plugins.inventoryRturlparseRtImportErrorturllib.parseR
(((sC/usr/lib/python2.7/site-packages/ansible/plugins/inventory/tower.pyt<module>s 8(


Anon7 - 2022
AnonSec Team