����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# -*- coding: utf-8 -*-
# This code is part of Ansible, but is an independent component.
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete work.
#
# Copyright (c) 2016 Thomas Krahn (@Nosmoht)
#
# Simplified BSD License (see LICENSES/BSD-2-Clause.txt or https://opensource.org/licenses/BSD-2-Clause)
# SPDX-License-Identifier: BSD-2-Clause
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json
import os
import socket
import uuid
import re
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.module_utils.six import PY3
from ansible.module_utils.six.moves.urllib.parse import quote
from ansible.module_utils.urls import fetch_url, HAS_GSSAPI
from ansible.module_utils.basic import env_fallback, AnsibleFallbackNotFound
def _env_then_dns_fallback(*args, **kwargs):
''' Load value from environment or DNS in that order'''
try:
result = env_fallback(*args, **kwargs)
if result == '':
raise AnsibleFallbackNotFound
return result
except AnsibleFallbackNotFound:
# If no host was given, we try to guess it from IPA.
# The ipa-ca entry is a standard entry that IPA will have set for
# the CA.
try:
return socket.gethostbyaddr(socket.gethostbyname('ipa-ca'))[0]
except Exception:
raise AnsibleFallbackNotFound
class IPAClient(object):
def __init__(self, module, host, port, protocol):
self.host = host
self.port = port
self.protocol = protocol
self.module = module
self.headers = None
self.timeout = module.params.get('ipa_timeout')
self.use_gssapi = False
def get_base_url(self):
return '%s://%s/ipa' % (self.protocol, self.host)
def get_json_url(self):
return '%s/session/json' % self.get_base_url()
def login(self, username, password):
if 'KRB5CCNAME' in os.environ and HAS_GSSAPI:
self.use_gssapi = True
elif 'KRB5_CLIENT_KTNAME' in os.environ and HAS_GSSAPI:
ccache = "MEMORY:" + str(uuid.uuid4())
os.environ['KRB5CCNAME'] = ccache
self.use_gssapi = True
else:
if not password:
if 'KRB5CCNAME' in os.environ or 'KRB5_CLIENT_KTNAME' in os.environ:
self.module.warn("In order to use GSSAPI, you need to install 'urllib_gssapi'")
self._fail('login', 'Password is required if not using '
'GSSAPI. To use GSSAPI, please set the '
'KRB5_CLIENT_KTNAME or KRB5CCNAME (or both) '
' environment variables.')
url = '%s/session/login_password' % self.get_base_url()
data = 'user=%s&password=%s' % (quote(username, safe=''), quote(password, safe=''))
headers = {'referer': self.get_base_url(),
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/plain'}
try:
resp, info = fetch_url(module=self.module, url=url, data=to_bytes(data), headers=headers, timeout=self.timeout)
status_code = info['status']
if status_code not in [200, 201, 204]:
self._fail('login', info['msg'])
self.headers = {'Cookie': info.get('set-cookie')}
except Exception as e:
self._fail('login', to_native(e))
if not self.headers:
self.headers = dict()
self.headers.update({
'referer': self.get_base_url(),
'Content-Type': 'application/json',
'Accept': 'application/json'})
def _fail(self, msg, e):
if 'message' in e:
err_string = e.get('message')
else:
err_string = e
self.module.fail_json(msg='%s: %s' % (msg, err_string))
def get_ipa_version(self):
response = self.ping()['summary']
ipa_ver_regex = re.compile(r'IPA server version (\d\.\d\.\d).*')
version_match = ipa_ver_regex.match(response)
ipa_version = None
if version_match:
ipa_version = version_match.groups()[0]
return ipa_version
def ping(self):
return self._post_json(method='ping', name=None)
def _post_json(self, method, name, item=None):
if item is None:
item = {}
url = '%s/session/json' % self.get_base_url()
data = dict(method=method)
# TODO: We should probably handle this a little better.
if method in ('ping', 'config_show', 'otpconfig_show'):
data['params'] = [[], {}]
elif method in ('config_mod', 'otpconfig_mod'):
data['params'] = [[], item]
else:
data['params'] = [[name], item]
try:
resp, info = fetch_url(module=self.module, url=url, data=to_bytes(json.dumps(data)),
headers=self.headers, timeout=self.timeout, use_gssapi=self.use_gssapi)
status_code = info['status']
if status_code not in [200, 201, 204]:
self._fail(method, info['msg'])
except Exception as e:
self._fail('post %s' % method, to_native(e))
if PY3:
charset = resp.headers.get_content_charset('latin-1')
else:
response_charset = resp.headers.getparam('charset')
if response_charset:
charset = response_charset
else:
charset = 'latin-1'
resp = json.loads(to_text(resp.read(), encoding=charset))
err = resp.get('error')
if err is not None:
self._fail('response %s' % method, err)
if 'result' in resp:
result = resp.get('result')
if 'result' in result:
result = result.get('result')
if isinstance(result, list):
if len(result) > 0:
return result[0]
else:
return {}
return result
return None
def get_diff(self, ipa_data, module_data):
result = []
for key in module_data.keys():
mod_value = module_data.get(key, None)
if isinstance(mod_value, list):
default = []
else:
default = None
ipa_value = ipa_data.get(key, default)
if isinstance(ipa_value, list) and not isinstance(mod_value, list):
mod_value = [mod_value]
if isinstance(ipa_value, list) and isinstance(mod_value, list):
mod_value = sorted(mod_value)
ipa_value = sorted(ipa_value)
if mod_value != ipa_value:
result.append(key)
return result
def modify_if_diff(self, name, ipa_list, module_list, add_method, remove_method, item=None, append=None):
changed = False
diff = list(set(ipa_list) - set(module_list))
if append is not True and len(diff) > 0:
changed = True
if not self.module.check_mode:
if item:
remove_method(name=name, item={item: diff})
else:
remove_method(name=name, item=diff)
diff = list(set(module_list) - set(ipa_list))
if len(diff) > 0:
changed = True
if not self.module.check_mode:
if item:
add_method(name=name, item={item: diff})
else:
add_method(name=name, item=diff)
return changed
def ipa_argument_spec():
return dict(
ipa_prot=dict(type='str', default='https', choices=['http', 'https'], fallback=(env_fallback, ['IPA_PROT'])),
ipa_host=dict(type='str', default='ipa.example.com', fallback=(_env_then_dns_fallback, ['IPA_HOST'])),
ipa_port=dict(type='int', default=443, fallback=(env_fallback, ['IPA_PORT'])),
ipa_user=dict(type='str', default='admin', fallback=(env_fallback, ['IPA_USER'])),
ipa_pass=dict(type='str', no_log=True, fallback=(env_fallback, ['IPA_PASS'])),
ipa_timeout=dict(type='int', default=10, fallback=(env_fallback, ['IPA_TIMEOUT'])),
validate_certs=dict(type='bool', default=True),
)
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| identity | Folder | 0755 |
|
|
| mh | Folder | 0755 |
|
|
| net_tools | Folder | 0755 |
|
|
| oracle | Folder | 0755 |
|
|
| remote_management | Folder | 0755 |
|
|
| source_control | Folder | 0755 |
|
|
| storage | Folder | 0755 |
|
|
| _filelock.py | File | 3.35 KB | 0644 |
|
| _mount.py | File | 1.71 KB | 0644 |
|
| _stormssh.py | File | 8.27 KB | 0644 |
|
| alicloud_ecs.py | File | 12.38 KB | 0644 |
|
| btrfs.py | File | 16.95 KB | 0644 |
|
| cloud.py | File | 8.15 KB | 0644 |
|
| cmd_runner.py | File | 10.79 KB | 0644 |
|
| csv.py | File | 2 KB | 0644 |
|
| database.py | File | 6.44 KB | 0644 |
|
| deps.py | File | 2.35 KB | 0644 |
|
| dimensiondata.py | File | 10.52 KB | 0644 |
|
| gandi_livedns_api.py | File | 7.4 KB | 0644 |
|
| gconftool2.py | File | 1023 B | 0644 |
|
| gitlab.py | File | 4.59 KB | 0644 |
|
| heroku.py | File | 1.25 KB | 0644 |
|
| hwc_utils.py | File | 12.56 KB | 0644 |
|
| ibm_sa_utils.py | File | 3.17 KB | 0644 |
|
| ilo_redfish_utils.py | File | 9.76 KB | 0644 |
|
| influxdb.py | File | 3.35 KB | 0644 |
|
| ipa.py | File | 8.38 KB | 0644 |
|
| jenkins.py | File | 1.06 KB | 0644 |
|
| known_hosts.py | File | 5.68 KB | 0644 |
|
| ldap.py | File | 4.4 KB | 0644 |
|
| linode.py | File | 939 B | 0644 |
|
| lxd.py | File | 5.12 KB | 0644 |
|
| manageiq.py | File | 16.23 KB | 0644 |
|
| memset.py | File | 4.22 KB | 0644 |
|
| module_helper.py | File | 1.45 KB | 0644 |
|
| ocapi_utils.py | File | 20.75 KB | 0644 |
|
| oneandone.py | File | 9.12 KB | 0644 |
|
| onepassword.py | File | 872 B | 0644 |
|
| oneview.py | File | 17.51 KB | 0644 |
|
| online.py | File | 3.83 KB | 0644 |
|
| opennebula.py | File | 12.04 KB | 0644 |
|
| pipx.py | File | 1.72 KB | 0644 |
|
| proxmox.py | File | 5.09 KB | 0644 |
|
| puppet.py | File | 3.88 KB | 0644 |
|
| pure.py | File | 4.07 KB | 0644 |
|
| rax.py | File | 11.26 KB | 0644 |
|
| redfish_utils.py | File | 135.75 KB | 0644 |
|
| redhat.py | File | 9.08 KB | 0644 |
|
| redis.py | File | 3.14 KB | 0644 |
|
| rundeck.py | File | 3.29 KB | 0644 |
|
| saslprep.py | File | 6.67 KB | 0644 |
|
| scaleway.py | File | 12.96 KB | 0644 |
|
| ssh.py | File | 723 B | 0644 |
|
| univention_umc.py | File | 7.53 KB | 0644 |
|
| utm_utils.py | File | 9.08 KB | 0644 |
|
| version.py | File | 878 B | 0644 |
|
| vexata.py | File | 3.14 KB | 0644 |
|
| wdc_redfish_utils.py | File | 23.09 KB | 0644 |
|
| xenserver.py | File | 30.1 KB | 0644 |
|
| xfconf.py | File | 1.33 KB | 0644 |
|