[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
pull/80028/head
Matt Davis 2 years ago committed by GitHub
parent 344230fca5
commit d5fd83265d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

@ -534,6 +534,10 @@ class TaskExecutor:
"(see https://docs.ansible.com/ansible/devel/reference_appendices/faq.html#argsplat-unsafe)") "(see https://docs.ansible.com/ansible/devel/reference_appendices/faq.html#argsplat-unsafe)")
variable_params.update(self._task.args) variable_params.update(self._task.args)
self._task.args = variable_params 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 # update no_log to task value, now that we have it templated
no_log = self._task.no_log no_log = self._task.no_log

@ -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

@ -0,0 +1,4 @@
#!/usr/bin/env bash
ansible-playbook playbook.yml "$@"

@ -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
Loading…
Cancel
Save