From e1d298ed61eed9250752fbd25ac8eae4944ec1bf Mon Sep 17 00:00:00 2001 From: Matt Davis <6775756+nitzmahone@users.noreply.github.com> Date: Wed, 8 Feb 2023 15:54:46 -0800 Subject: [PATCH] don't ignore templated _raw_params that k=v parser failed to parse (#79913) fixes #79862 --- changelogs/fragments/79862-fix-varargs.yml | 2 ++ lib/ansible/executor/task_executor.py | 4 ++++ test/integration/targets/tasks/playbook.yml | 14 +++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/79862-fix-varargs.yml diff --git a/changelogs/fragments/79862-fix-varargs.yml b/changelogs/fragments/79862-fix-varargs.yml new file mode 100644 index 00000000000..c455d7e563c --- /dev/null +++ b/changelogs/fragments/79862-fix-varargs.yml @@ -0,0 +1,2 @@ +bugfixes: +- TaskExecutor - don't ignore templated _raw_params that k=v parser failed to parse (https://github.com/ansible/ansible/issues/79862) diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index c7a36fad264..5dc45d9d6e3 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -515,6 +515,10 @@ class TaskExecutor: "(see https://docs.ansible.com/ansible/devel/reference_appendices/faq.html#argsplat-unsafe)") variable_params.update(self._task.args) self._task.args = variable_params + else: + # if we didn't get a dict, it means there's garbage remaining after k=v parsing, just give up + # see https://github.com/ansible/ansible/issues/79862 + raise AnsibleError(f"invalid or malformed argument: '{variable_params}'") # update no_log to task value, now that we have it templated no_log = self._task.no_log diff --git a/test/integration/targets/tasks/playbook.yml b/test/integration/targets/tasks/playbook.yml index 04f04217160..10bd8591bd7 100644 --- a/test/integration/targets/tasks/playbook.yml +++ b/test/integration/targets/tasks/playbook.yml @@ -9,4 +9,16 @@ # ensure we properly test for an action name, not a task name when cheking for a meta task - name: "meta" debug: - msg: Hello \ No newline at end of file + msg: Hello + + - name: ensure malformed raw_params on arbitrary actions are not ignored + debug: + garbage {{"with a template"}} + ignore_errors: true + register: bad_templated_raw_param + + - assert: + that: + - bad_templated_raw_param is failed + - | + "invalid or malformed argument: 'garbage with a template'" in bad_templated_raw_param.msg