diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index 1c62dd569d7..79f78d728f3 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -75,6 +75,8 @@ def to_json(a, *args, **kw): def to_nice_json(a, indent=4, sort_keys=True, *args, **kw): '''Make verbose, human-readable JSON''' + # TODO separators can be potentially exposed to the user as well + kw.pop('separators', None) return to_json(a, indent=indent, sort_keys=sort_keys, separators=(',', ': '), *args, **kw) diff --git a/lib/ansible/plugins/filter/to_nice_json.yml b/lib/ansible/plugins/filter/to_nice_json.yml index fa31b269de6..abaeee0c071 100644 --- a/lib/ansible/plugins/filter/to_nice_json.yml +++ b/lib/ansible/plugins/filter/to_nice_json.yml @@ -40,12 +40,16 @@ DOCUMENTATION: default: False type: bool sort_keys: - description: Affects sorting of dictionary keys. + description: Affects sorting of dictionary keys. Passed to an underlying C(json.dumps) call. default: True - type: bool + type: bool + indent: + description: Specifies an indentation level. Passed to an underlying C(json.dumps) call. + default: 4 + type: int notes: - Both O(vault_to_text) and O(preprocess_unsafe) defaulted to V(False) between Ansible 2.9 and 2.12. - - 'These parameters to C(json.dumps) will be ignored, they are overridden for internal use: I(cls), I(default), I(indent), I(separators), I(sort_keys).' + - 'These parameters to C(json.dumps) will be ignored, they are overridden for internal use: I(cls), I(default), I(separators).' EXAMPLES: | # dump variable in a template to create a nicely formatted JSON document