From 480d47d071cc6ed08b80209a3fa75b64311ea648 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 2 Dec 2021 11:02:38 -0500 Subject: [PATCH] reset defaults for json filters (#76349) * reset defaults for json filters these had change on unification of json parsing/dumping now they behave like before, but are still controllable by user. --- changelogs/fragments/json_filter_fix.yml | 2 ++ lib/ansible/plugins/filter/core.py | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 changelogs/fragments/json_filter_fix.yml diff --git a/changelogs/fragments/json_filter_fix.yml b/changelogs/fragments/json_filter_fix.yml new file mode 100644 index 00000000000..b00401f3db5 --- /dev/null +++ b/changelogs/fragments/json_filter_fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - to_json/to_nice_json filters defaults back to unvaulting/no unsafe packing. diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index 703575c0fc3..745443f27cd 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -65,6 +65,13 @@ def to_nice_yaml(a, indent=4, *args, **kw): def to_json(a, *args, **kw): ''' Convert the value to JSON ''' + + # defualts for filters + if 'vault_to_text' not in kw: + kw['vault_to_text'] = True + if 'preprocess_unsafe' not in kw: + kw['preprocess_unsafe'] = False + return json.dumps(a, cls=AnsibleJSONEncoder, *args, **kw)