From 3779c1f278685c5a8d7f78942ce649f6805a5775 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 14 Feb 2022 08:21:17 -0600 Subject: [PATCH] restore inadvertently deleted default for convert_data. Fixes #77004 (#77016) --- changelogs/fragments/77004-restore-missing-default.yml | 3 +++ lib/ansible/plugins/lookup/template.py | 1 + test/integration/targets/lookup_template/tasks/main.yml | 7 +++++++ test/integration/targets/lookup_template/templates/dict.j2 | 1 + 4 files changed, 12 insertions(+) create mode 100644 changelogs/fragments/77004-restore-missing-default.yml create mode 100644 test/integration/targets/lookup_template/templates/dict.j2 diff --git a/changelogs/fragments/77004-restore-missing-default.yml b/changelogs/fragments/77004-restore-missing-default.yml new file mode 100644 index 00000000000..a55d7e56580 --- /dev/null +++ b/changelogs/fragments/77004-restore-missing-default.yml @@ -0,0 +1,3 @@ +bugfixes: +- template lookup - restore inadvertently deleted default for ``convert_data`` + (https://github.com/ansible/ansible/issues/77004) diff --git a/lib/ansible/plugins/lookup/template.py b/lib/ansible/plugins/lookup/template.py index c400a08fb51..6e98d282819 100644 --- a/lib/ansible/plugins/lookup/template.py +++ b/lib/ansible/plugins/lookup/template.py @@ -20,6 +20,7 @@ DOCUMENTATION = """ description: - Whether to convert YAML into data. If False, strings that are YAML will be left untouched. - Mutually exclusive with the jinja2_native option. + default: true variable_start_string: description: The string marking the beginning of a print statement. default: '{{' diff --git a/test/integration/targets/lookup_template/tasks/main.yml b/test/integration/targets/lookup_template/tasks/main.yml index 36a8ee31325..9ebdf0c5ac9 100644 --- a/test/integration/targets/lookup_template/tasks/main.yml +++ b/test/integration/targets/lookup_template/tasks/main.yml @@ -25,3 +25,10 @@ - assert: that: - "hello_world_comment|trim == 'Hello world!'" + +# 77004 +- assert: + that: + - lookup('template', 'dict.j2') is mapping + - lookup('template', 'dict.j2', convert_data=True) is mapping + - lookup('template', 'dict.j2', convert_data=False) is not mapping diff --git a/test/integration/targets/lookup_template/templates/dict.j2 b/test/integration/targets/lookup_template/templates/dict.j2 new file mode 100644 index 00000000000..0439155b220 --- /dev/null +++ b/test/integration/targets/lookup_template/templates/dict.j2 @@ -0,0 +1 @@ +{"foo": "{{ 'bar' }}"}