summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/templating_lookups
diff options
context:
space:
mode:
authorJoseph Torcasso <87090265+jatorcasso@users.noreply.github.com>2022-05-17 18:24:53 +0200
committerGitHub <noreply@github.com>2022-05-17 18:24:53 +0200
commitc9ce7d08a256646abdaccc80b480b8b9c2df9f1b (patch)
tree931f72ab680a14e0955be91a8f433c1355855065 /test/integration/targets/templating_lookups
parentRestrict role loading .. to role ... (#77683) (diff)
downloadansible-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')
-rwxr-xr-xtest/integration/targets/templating_lookups/runme.sh2
-rw-r--r--test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py6
-rw-r--r--test/integration/targets/templating_lookups/template_lookups/tasks/main.yml11
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