diff --git a/changelogs/fragments/79839-lookup-option-name.yml b/changelogs/fragments/79839-lookup-option-name.yml new file mode 100644 index 00000000000..9804c654887 --- /dev/null +++ b/changelogs/fragments/79839-lookup-option-name.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - templates - Fixed `TypeError` when a lookup plugin has an option called `name`. diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index f6513042022..f8246a274d6 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -810,12 +810,12 @@ class Templar: return now - def _query_lookup(self, name, *args, **kwargs): + def _query_lookup(self, name, /, *args, **kwargs): ''' wrapper for lookup, force wantlist true''' kwargs['wantlist'] = True return self._lookup(name, *args, **kwargs) - def _lookup(self, name, *args, **kwargs): + def _lookup(self, name, /, *args, **kwargs): instance = lookup_loader.get(name, loader=self._loader, templar=self) if instance is None: diff --git a/test/integration/targets/lookup-option-name/aliases b/test/integration/targets/lookup-option-name/aliases new file mode 100644 index 00000000000..498fedd558e --- /dev/null +++ b/test/integration/targets/lookup-option-name/aliases @@ -0,0 +1,2 @@ +shippable/posix/group4 +context/controller diff --git a/test/integration/targets/lookup-option-name/tasks/main.yml b/test/integration/targets/lookup-option-name/tasks/main.yml new file mode 100644 index 00000000000..4f248c84b34 --- /dev/null +++ b/test/integration/targets/lookup-option-name/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- debug: + msg: "{{ lookup('vars', name='test') }}" + +- debug: + msg: "{{ query('vars', name='test') }}"