003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/salt/pillar
usr
/
local
/
lib
/
python3.8
/
site-packages
/
salt
/
pillar
/
📁
..
📄
__init__.py
(48.72 KB)
📁
__pycache__
📄
azureblob.py
(13.88 KB)
📄
cmd_json.py
(787 B)
📄
cmd_yaml.py
(893 B)
📄
cmd_yamlex.py
(674 B)
📄
cobbler.py
(1.64 KB)
📄
confidant.py
(3.29 KB)
📄
consul_pillar.py
(11.61 KB)
📄
csvpillar.py
(1.85 KB)
📄
digicert.py
(1007 B)
📄
django_orm.py
(7.74 KB)
📄
ec2_pillar.py
(10.12 KB)
📄
etcd_pillar.py
(2.36 KB)
📄
extra_minion_data_in_pillar.py
(2.18 KB)
📄
file_tree.py
(18.03 KB)
📄
foreman.py
(3.66 KB)
📄
git_pillar.py
(19.61 KB)
📄
gpg.py
(560 B)
📄
hg_pillar.py
(3.19 KB)
📄
hiera.py
(846 B)
📄
http_json.py
(2.43 KB)
📄
http_yaml.py
(2.43 KB)
📄
libvirt.py
(5.78 KB)
📄
makostack.py
(21.99 KB)
📄
mongo.py
(5.6 KB)
📄
mysql.py
(3.76 KB)
📄
nacl.py
(744 B)
📄
netbox.py
(29.5 KB)
📄
neutron.py
(2.41 KB)
📄
nodegroups.py
(1.7 KB)
📄
pepa.py
(20.98 KB)
📄
pillar_ldap.py
(10.95 KB)
📄
postgres.py
(2.82 KB)
📄
puppet.py
(846 B)
📄
reclass_adapter.py
(4 KB)
📄
redismod.py
(3.28 KB)
📄
rethinkdb_pillar.py
(4.71 KB)
📄
s3.py
(14.4 KB)
📄
saltclass.py
(1.49 KB)
📄
sql_base.py
(15.38 KB)
📄
sqlcipher.py
(3.42 KB)
📄
sqlite3.py
(2.67 KB)
📄
stack.py
(22.07 KB)
📄
svn_pillar.py
(5.74 KB)
📄
varstack_pillar.py
(1.1 KB)
📄
vault.py
(4.03 KB)
📄
venafi.py
(966 B)
📄
virtkey.py
(586 B)
📄
vmware_pillar.py
(16.83 KB)
Editing: http_yaml.py
""" A module that adds data to the Pillar structure retrieved by an http request Configuring the HTTP_YAML ext_pillar ==================================== Set the following Salt config to setup an http endpoint as the external pillar source: .. code-block:: yaml ext_pillar: - http_yaml: url: http://example.com/api/minion_id ::TODO:: username: username password: password If the with_grains parameter is set, grain keys wrapped in can be provided (wrapped in <> brackets) in the url in order to populate pillar data based on the grain value. .. code-block:: yaml ext_pillar: - http_yaml: url: http://example.com/api/<nodename> with_grains: True .. versionchanged:: 2018.3.0 If %s is present in the url, it will be automatically replaced by the minion_id: .. code-block:: yaml ext_pillar: - http_json: url: http://example.com/api/%s Module Documentation ==================== """ import logging import re import urllib.parse log = logging.getLogger(__name__) def __virtual__(): return True def ext_pillar(minion_id, pillar, url, with_grains=False): # pylint: disable=W0613 """ Read pillar data from HTTP response. :param str url: Url to request. :param bool with_grains: Whether to substitute strings in the url with their grain values. :return: A dictionary of the pillar data to add. :rtype: dict """ url = url.replace("%s", urllib.parse.quote(minion_id)) grain_pattern = r"<(?P<grain_name>.*?)>" if with_grains: # Get the value of the grain and substitute each grain # name for the url-encoded version of its grain value. for match in re.finditer(grain_pattern, url): grain_name = match.group("grain_name") grain_value = __salt__["grains.get"](grain_name, None) if not grain_value: log.error("Unable to get minion '%s' grain: %s", minion_id, grain_name) return {} grain_value = urllib.parse.quote(str(grain_value)) url = re.sub("<{}>".format(grain_name), grain_value, url) log.debug("Getting url: %s", url) data = __salt__["http.query"](url=url, decode=True, decode_type="yaml") if "dict" in data: return data["dict"] log.error("Error on minion '%s' http query: %s\nMore Info:\n", minion_id, url) for key in data: log.error("%s: %s", key, data[key]) return {}
Upload File
Create Folder