mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
add namespace to http_json external pillar method
add a namespace option just like csvpillar
This commit is contained in:
parent
dcfe24fed7
commit
35265421e4
1 changed files with 10 additions and 1 deletions
|
@ -12,6 +12,7 @@ Set the following Salt config to setup http json result as external pillar sourc
|
|||
ext_pillar:
|
||||
- http_json:
|
||||
url: http://example.com/api/minion_id
|
||||
namespace: 'subkey'
|
||||
username: username
|
||||
password: password
|
||||
header_dict: None
|
||||
|
@ -20,6 +21,9 @@ Set the following Salt config to setup http json result as external pillar sourc
|
|||
You can pass additional parameters, they will be added to the http.query call
|
||||
:py:func:`utils.http.query function <salt.utils.http.query>`:
|
||||
|
||||
.. versionchanged:: TBD
|
||||
If namespace is defined, the data will be added under the specified subkeys in the Pillar structure.
|
||||
|
||||
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.
|
||||
|
||||
|
@ -65,6 +69,7 @@ def ext_pillar(
|
|||
auth=None,
|
||||
username=None,
|
||||
password=None,
|
||||
namespace=None,
|
||||
): # pylint: disable=W0613
|
||||
"""
|
||||
Read pillar data from HTTP response.
|
||||
|
@ -75,6 +80,7 @@ def ext_pillar(
|
|||
:param auth: special auth if needed
|
||||
:param str username: username for auth
|
||||
:param str pasword: password for auth
|
||||
:param str namespace: (Optional) A pillar key to namespace the values under.
|
||||
|
||||
:return: A dictionary of the pillar data to add.
|
||||
:rtype: dict
|
||||
|
@ -109,7 +115,10 @@ def ext_pillar(
|
|||
)
|
||||
|
||||
if "dict" in data:
|
||||
return data["dict"]
|
||||
if namespace:
|
||||
return {namespace: data["dict"]}
|
||||
else:
|
||||
return data["dict"]
|
||||
|
||||
log.error("Error on minion '%s' http query: %s\nMore Info:\n", minion_id, url)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue