AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.15.149.130
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/foreman.pyo
�
��\c@`sddlmZmZmZeZdZdZddlZddl	m
Z
ddlmZddl
mZddlmZmZdd	lmZmZy4ddlZeej�ed
�kr�e�nWnek
r�ed��nXddlmZd
eefd��YZdS(i(tabsolute_importtdivisiontprint_functionsD
    name: foreman
    plugin_type: inventory
    short_description: foreman inventory source
    version_added: "2.6"
    requirements:
        - requests >= 1.1
    description:
        - Get inventory hosts from the foreman service.
        - "Uses a configuration file as an inventory source, it must end in ``.foreman.yml`` or ``.foreman.yaml`` and has a ``plugin: foreman`` entry."
    extends_documentation_fragment:
        - inventory_cache
    options:
      plugin:
        description: the name of this plugin, it should alwys be set to 'foreman' for this plugin to recognize it as it's own.
        required: True
        choices: ['foreman']
      url:
        description: url to foreman
        default: 'http://localhost:300'
      user:
        description: foreman authentication user
        required: True
      password:
        description: foreman authentication password
        required: True
      validate_certs:
        description: verify SSL certificate if using https
        type: boolean
        default: False
      group_prefix:
        description: prefix to apply to foreman groups
        default: foreman_
      vars_prefix:
        description: prefix to apply to host variables, does not include facts nor params
        default: foreman_
      want_facts:
        description: Toggle, if True the plugin will retrieve host facts from the server
        type: boolean
        default: False
      want_params:
        description: Toggle, if true the inventory will retrieve 'all_parameters' information as host vars
        type: boolean
        default: False
sy
# my.foreman.yml
plugin: foreman
url: http://localhost:2222
user: ansible-tester
password: secure
validate_certs: False
N(tMutableMapping(tLooseVersion(tAnsibleError(tto_bytest	to_native(tBaseInventoryPlugint	Cacheables1.1.0s=This script requires python-requests 1.1 as a minimum version(t
HTTPBasicAuthtInventoryModulecB`s}eZdZdZd�Zd�Zd�Zd
d�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zed�ZRS(s< Host inventory parser for ansible using foreman as source. tforemancC`s;tt|�j�d|_d|_d|_d|_dS(N(tsuperRt__init__tNonetforeman_urltsessiont	cache_keyt	use_cache(tself((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyRXs
			cC`sMt}tt|�j|�rI|jd�r6t}qI|jjd�n|S(Nsforeman.yamlsforeman.ymlsOSkipping due to inventory source not ending in "foreman.yaml" nor "foreman.yml"(sforeman.yamlsforeman.yml(tFalseR
Rtverify_filetendswithtTruetdisplaytvvv(Rtpathtvalid((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyRcs	cC`sd|js]tj�|_t|jd�t|jd���|j_|jd�|j_n|jS(Ntusertpasswordtvalidate_certs(RtrequestsR
t
get_optionRtauthtverify(R((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyt_get_sessionms
	-cC`s�|js(||jj|ji�kr�|j|jkrTidd6|j|j<ng}|j�}idd6dd6}x�trw|j|d|�}|r�|j|kr�Pn|j�|j�}d|kr�|}Pq}t	|dt
�r�|d}Pq}||d}t|�|d	kr&Pnt|d�d
krd|jj
d|d	t|�f�Pn|dcd7<q}W||j|j|<n|j|j|S(Ntturlitpagei�tper_pagetparamstresultstsubtotalis9Did not make any progress during loop. expected %d got %d(Rt_cachetgetRR$Rtstatus_codetraise_for_statustjsont
isinstanceRtlenRtwarning(RR&t
ignore_errorsR*tsR)tretR0((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyt	_get_jsonts6(	

$cC`s|jd|j�S(Ns%s/api/v2/hosts(R7R(R((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyt
_get_hosts�scC`svd|j|f}|j|dg�}|sRt|t�sR|jdt�reiigd6}n|jd�dS(Ns%s/api/v2/hosts/%si�tall_parametersi(RR7R1RR-R(RthidR&R6((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyt_get_all_params_by_id�s
*cC`s d|j|f}|j|�S(Ns%s/api/v2/hosts/%s/facts(RR7(RR:R&((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyt_get_facts_by_id�scC`sy|j|d�}t|j��dkr4i}nAt|j��dkret|j��d}ntd|��|S(s Fetch all host facts of the hosttidiis,More than one set of facts returned for '%s'(R<R2tvaluestlistt
ValueError(RthostR6tfacts((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyt
_get_facts�s	cC`s%d}tj|d|jdd��S(s�Converts 'bad' characters in a string to underscores so they can be used as Ansible groups
        #> ForemanInventory.to_safe("foo-bar baz")
        'foo_barbaz'
        s[^A-Za-z0-9\_]t_t R%(tretsubtreplace(Rtwordtregex((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pytto_safe�scC`sJxC|j�D]5}|jd�r
|jj|d�|jd|jd��}|r�|jd|jd�|j�f�}|jj|�|jj||d�ny�x�|j	�D]\}}|dkr�y+|jj
|d|jd�||�Wq8tk
r4}|jj
d||t|�f�q8Xq�q�WWn7tk
rv}|jj
d|dt|�f�nX|jd	�r
x�|j|d
�j	�D]c\}}y|jj
|d||�Wq�tk
r}|jj
d||t|�f�q�Xq�Wn|jd�rB|jj
|dd
|j|��qBq
q
WdS(Ntnamethostgroup_titlethostgroup_names%s%stgroup_prefixtvars_prefixs7Could not set host info hostvar for %s, skipping %s: %ss,Could not get host info for %s, skipping: %stwant_paramsR=s7Could not set parameter hostvar for %s, skipping %s: %st
want_factst
ansible_facts(snameRMRN(R8R-t	inventorytadd_hostRKR!tlowert	add_groupt	add_childtitemstset_variableR@RR3RR;RC(RRAt
group_nametktvte((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyt	_populate�s2(+2(&.cC`sstt|�j|||�|j|�|jd�|_|j|�|_|o_|jd�|_|j	�dS(NR&tcache(
R
Rtparset_read_config_dataR!Rt
get_cache_keyRRR_(RRTtloaderRR`((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyRa�s
N(t__name__t
__module__t__doc__tNAMERRR$RR7R8R;R<RCRKR_RRa(((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyRSs		
	.						%(t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONtEXAMPLESRFtcollectionsRtdistutils.versionRtansible.errorsRtansible.module_utils._textRRtansible.plugins.inventoryRR	R t__version__tImportErrort
requests.authR
R(((sE/usr/lib/python2.7/site-packages/ansible/plugins/inventory/foreman.pyt<module>s".	



Anon7 - 2022
AnonSec Team