summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Davis <6775756+nitzmahone@users.noreply.github.com>2023-02-15 11:34:47 -0800
committerGitHub <noreply@github.com>2023-02-15 13:34:47 -0600
commita082726ef28c3d6763259aa42d9c1191e2a0f77e (patch)
tree949fdadd176897ad65f66a584843e61db9bb4aa6
parentc0395c486a6a9e42f6d81eebfb99906acd665e3a (diff)
downloadansible-a082726ef28c3d6763259aa42d9c1191e2a0f77e.tar.gz
[2.14] don't ignore templated _raw_params that k=v parser failed to parse (#79913) (#79964)
* don't ignore templated _raw_params that k=v parser failed to parse (#79913) fixes #79862 (cherry picked from commit e1d298ed61eed9250752fbd25ac8eae4944ec1bf) * backport test change to runme.sh
-rw-r--r--changelogs/fragments/79862-fix-varargs.yml2
-rw-r--r--lib/ansible/executor/task_executor.py4
-rw-r--r--test/integration/targets/tasks/playbook.yml19
-rwxr-xr-xtest/integration/targets/tasks/runme.sh3
-rw-r--r--test/integration/targets/tasks/tasks/main.yml4
5 files changed, 28 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 1f35031f8c..02ace8f50e 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
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..594447bd94
--- /dev/null
+++ b/test/integration/targets/tasks/runme.sh
@@ -0,0 +1,3 @@
+#!/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