mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Enabled unsafe and vault in JSON (#38759)
* allow to load json marked as unsafe or vault * centralized json code/decode, add vault support * use generics to allow for more varied inputs * allow inventory to dump vault w/o decrypting * override simplejson also * add entry for unsafe also * load vaulted and unsafe json, support unvaulting if secrets provided
This commit is contained in:
parent
ff16e993be
commit
cbb6a7f4e8
5 changed files with 99 additions and 56 deletions
|
@ -193,8 +193,9 @@ class InventoryCLI(CLI):
|
|||
from ansible.parsing.yaml.dumper import AnsibleDumper
|
||||
results = yaml.dump(stuff, Dumper=AnsibleDumper, default_flow_style=False)
|
||||
else:
|
||||
from ansible.module_utils.basic import jsonify
|
||||
results = jsonify(stuff, sort_keys=True, indent=4)
|
||||
import json
|
||||
from ansible.parsing.ajson import AnsibleJSONEncoder
|
||||
results = json.dumps(stuff, cls=AnsibleJSONEncoder, sort_keys=True, indent=4)
|
||||
|
||||
return results
|
||||
|
||||
|
@ -210,9 +211,9 @@ class InventoryCLI(CLI):
|
|||
except AttributeError:
|
||||
try:
|
||||
if isinstance(entity, Host):
|
||||
data.update(plugin.get_host_vars(entity.name))
|
||||
data = combine_vars(data, plugin.get_host_vars(entity.name))
|
||||
else:
|
||||
data.update(plugin.get_group_vars(entity.name))
|
||||
data = combine_vars(data, plugin.get_group_vars(entity.name))
|
||||
except AttributeError:
|
||||
if hasattr(plugin, 'run'):
|
||||
raise AnsibleError("Cannot use v1 type vars plugin %s from %s" % (plugin._load_name, plugin._original_path))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue