diff options
author | Joseph Torcasso <87090265+jatorcasso@users.noreply.github.com> | 2022-05-17 18:24:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 18:24:53 +0200 |
commit | c9ce7d08a256646abdaccc80b480b8b9c2df9f1b (patch) | |
tree | 931f72ab680a14e0955be91a8f433c1355855065 /test/integration/targets/templating_lookups | |
parent | Restrict role loading .. to role ... (#77683) (diff) | |
download | ansible-c9ce7d08a256646abdaccc80b480b8b9c2df9f1b.tar.xz ansible-c9ce7d08a256646abdaccc80b480b8b9c2df9f1b.zip |
template/__init__.py - fix KeyError when wantlist=False with non-list
Diffstat (limited to 'test/integration/targets/templating_lookups')
3 files changed, 18 insertions, 1 deletions
diff --git a/test/integration/targets/templating_lookups/runme.sh b/test/integration/targets/templating_lookups/runme.sh index b900c153de..60b3923b1a 100755 --- a/test/integration/targets/templating_lookups/runme.sh +++ b/test/integration/targets/templating_lookups/runme.sh @@ -2,7 +2,7 @@ set -eux -ANSIBLE_ROLES_PATH=./ UNICODE_VAR=café ansible-playbook runme.yml "$@" +ANSIBLE_LOOKUP_PLUGINS=. ANSIBLE_ROLES_PATH=./ UNICODE_VAR=café ansible-playbook runme.yml "$@" ansible-playbook template_lookup_vaulted/playbook.yml --vault-password-file template_lookup_vaulted/test_vault_pass "$@" diff --git a/test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py b/test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py new file mode 100644 index 0000000000..436ceaf391 --- /dev/null +++ b/test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py @@ -0,0 +1,6 @@ +from ansible.plugins.lookup import LookupBase + + +class LookupModule(LookupBase): + def run(self, terms, variables, **kwargs): + return {'one': 1, 'two': 2} diff --git a/test/integration/targets/templating_lookups/template_lookups/tasks/main.yml b/test/integration/targets/templating_lookups/template_lookups/tasks/main.yml index f240a2340d..430ac91777 100644 --- a/test/integration/targets/templating_lookups/template_lookups/tasks/main.yml +++ b/test/integration/targets/templating_lookups/template_lookups/tasks/main.yml @@ -87,4 +87,15 @@ that: - password1 != password2 +# 77788 - KeyError when wantlist=False with dict returned +- name: Test that dicts can be parsed with wantlist false + set_fact: + dict_wantlist_true: "{{ lookup('77788', wantlist=True) }}" + dict_wantlist_false: "{{ lookup('77788', wantlist=False) }}" + +- assert: + that: + - dict_wantlist_true is mapping + - dict_wantlist_false is string + - include_tasks: ./errors.yml |