Prevent ansible_failed_task from further templating (#74290)
* Prevent ansible_failed_task from further templating Fixes #74036 * Add changelog
This commit is contained in:
parent
c6945de899
commit
664531d7d6
4 changed files with 23 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- Prevent ``ansible_failed_task`` from further templating (https://github.com/ansible/ansible/issues/74036)
|
|
@ -50,6 +50,7 @@ from ansible.playbook.task_include import TaskInclude
|
|||
from ansible.plugins import loader as plugin_loader
|
||||
from ansible.template import Templar
|
||||
from ansible.utils.display import Display
|
||||
from ansible.utils.unsafe_proxy import wrap_var
|
||||
from ansible.utils.vars import combine_vars
|
||||
from ansible.vars.clean import strip_internal_keys, module_response_deepcopy
|
||||
|
||||
|
@ -572,7 +573,7 @@ class StrategyBase:
|
|||
self._variable_manager.set_nonpersistent_facts(
|
||||
original_host.name,
|
||||
dict(
|
||||
ansible_failed_task=original_task.serialize(),
|
||||
ansible_failed_task=wrap_var(original_task.serialize()),
|
||||
ansible_failed_result=task_result._result,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -103,3 +103,5 @@ rm -f role_complete_test.out
|
|||
|
||||
# test notify inheritance
|
||||
ansible-playbook inherit_notify.yml "$@"
|
||||
|
||||
ansible-playbook unsafe_failed_task.yml "$@"
|
||||
|
|
17
test/integration/targets/blocks/unsafe_failed_task.yml
Normal file
17
test/integration/targets/blocks/unsafe_failed_task.yml
Normal file
|
@ -0,0 +1,17 @@
|
|||
- hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
- data: {}
|
||||
tasks:
|
||||
- block:
|
||||
- name: template error
|
||||
debug:
|
||||
msg: "{{ data.value }}"
|
||||
rescue:
|
||||
- debug:
|
||||
msg: "{{ ansible_failed_task.action }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- ansible_failed_task.name == "template error"
|
||||
- ansible_failed_task.action == "debug"
|
Loading…
Reference in a new issue