diff options
author | Matt Davis <6775756+nitzmahone@users.noreply.github.com> | 2023-02-15 11:34:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-15 13:34:54 -0600 |
commit | d5fd83265d3a050b02cdb9293708ae4deed8cbde (patch) | |
tree | 4032f2a7b3c8fd040083c4c419c5eda7fcdd66b3 | |
parent | 344230fca5bc982ac1a46da7445c2812b0b92b1f (diff) | |
download | ansible-d5fd83265d3a050b02cdb9293708ae4deed8cbde.tar.gz |
[2.13] don't ignore templated _raw_params that k=v parser failed to parse (#79913) (#79965)
* don't ignore templated _raw_params that k=v parser failed to parse (#79913)
fixes #79862
* backport test changes
-rw-r--r-- | changelogs/fragments/79862-fix-varargs.yml | 2 | ||||
-rw-r--r-- | lib/ansible/executor/task_executor.py | 4 | ||||
-rw-r--r-- | test/integration/targets/tasks/playbook.yml | 19 | ||||
-rwxr-xr-x | test/integration/targets/tasks/runme.sh | 4 | ||||
-rw-r--r-- | test/integration/targets/tasks/tasks/main.yml | 4 |
5 files changed, 29 insertions, 4 deletions
diff --git a/changelogs/fragments/79862-fix-varargs.yml b/changelogs/fragments/79862-fix-varargs.yml new file mode 100644 index 0000000000..c455d7e563 --- /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 baeb1d1bea..4fad7e7ce2 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -534,6 +534,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 new file mode 100644 index 0000000000..80d9f8b1e8 --- /dev/null +++ b/test/integration/targets/tasks/playbook.yml @@ -0,0 +1,19 @@ +- hosts: localhost + gather_facts: false + tasks: + # make sure tasks with an undefined variable in the name are gracefully handled + - name: "Task name with undefined variable: {{ not_defined }}" + debug: + 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 diff --git a/test/integration/targets/tasks/runme.sh b/test/integration/targets/tasks/runme.sh new file mode 100755 index 0000000000..2d78eafc07 --- /dev/null +++ b/test/integration/targets/tasks/runme.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +ansible-playbook playbook.yml "$@" + diff --git a/test/integration/targets/tasks/tasks/main.yml b/test/integration/targets/tasks/tasks/main.yml deleted file mode 100644 index f6ac1114d0..0000000000 --- a/test/integration/targets/tasks/tasks/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -# make sure tasks with an undefined variable in the name are gracefully handled -- name: "Task name with undefined variable: {{ not_defined }}" - debug: - msg: Hello |