Skip to content

Commit

Permalink
[2.14] don't ignore templated _raw_params that k=v parser failed to p…
Browse files Browse the repository at this point in the history
…arse (#79913) (#79964)

* don't ignore templated _raw_params that k=v parser failed to parse (#79913)

fixes #79862

(cherry picked from commit e1d298e)

* backport test change to runme.sh
  • Loading branch information
nitzmahone committed Feb 15, 2023
1 parent c0395c4 commit a082726
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/79862-fix-varargs.yml
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions lib/ansible/executor/task_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@ def _execute(self, variables=None):
"(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
Expand Down
19 changes: 19 additions & 0 deletions test/integration/targets/tasks/playbook.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions test/integration/targets/tasks/runme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ansible-playbook playbook.yml "$@"
4 changes: 0 additions & 4 deletions test/integration/targets/tasks/tasks/main.yml

This file was deleted.

0 comments on commit a082726

Please sign in to comment.