mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #5783 from jimi-c/issue_5756
Fixing traceback caused by incorrect argument passing to json.dumps
This commit is contained in:
commit
97d6e5e60c
2 changed files with 9 additions and 3 deletions
|
@ -30,9 +30,13 @@ def to_nice_yaml(*a, **kw):
|
|||
'''Make verbose, human readable yaml'''
|
||||
return yaml.safe_dump(*a, indent=4, allow_unicode=True, default_flow_style=False, **kw)
|
||||
|
||||
def to_nice_json(*a, **kw):
|
||||
def to_json(a, *args, **kw):
|
||||
''' Convert the value to JSON '''
|
||||
return json.dumps(a, *args, **kw)
|
||||
|
||||
def to_nice_json(a, *args, **kw):
|
||||
'''Make verbose, human readable JSON'''
|
||||
return json.dumps(*a, indent=4, sort_keys=True, **kw)
|
||||
return json.dumps(a, indent=4, sort_keys=True, *args, **kw)
|
||||
|
||||
def failed(*a, **kw):
|
||||
''' Test if task result yields failed '''
|
||||
|
@ -148,7 +152,7 @@ class FilterModule(object):
|
|||
'b64encode': base64.b64encode,
|
||||
|
||||
# json
|
||||
'to_json': json.dumps,
|
||||
'to_json': to_json,
|
||||
'to_nice_json': to_nice_json,
|
||||
'from_json': json.loads,
|
||||
|
||||
|
|
|
@ -547,6 +547,8 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
|
|||
except TypeError, te:
|
||||
if 'StrictUndefined' in str(te):
|
||||
raise errors.AnsibleUndefinedVariable("unable to look up a name or access an attribute in template string")
|
||||
else:
|
||||
raise errors.AnsibleError("an unexpected type error occured. Error was %s" % te)
|
||||
return res
|
||||
except (jinja2.exceptions.UndefinedError, errors.AnsibleUndefinedVariable):
|
||||
if fail_on_undefined:
|
||||
|
|
Loading…
Reference in a new issue