mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Fix 'task name is not templated in retry callback' (add task_name property to TaskResult) (#21214)
Fix 'task name is not templated in retry callback' Add a task_name property to TaskResult that knows to check in TaskResult._task_fields. Add integration test for v2_retry_runner callback Fixes #18236
This commit is contained in:
parent
78c4f03e50
commit
8830cde28d
6 changed files with 56 additions and 2 deletions
|
@ -0,0 +1 @@
|
|||
posix/ci/group3
|
13
test/integration/targets/callback_retry_task_name/runme.sh
Executable file
13
test/integration/targets/callback_retry_task_name/runme.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
# we are looking to verify the callback for v2_retry_runner gets a correct task name, include
|
||||
# if the value needs templating based on results of previous tasks
|
||||
OUTFILE="callback_retry_task_name.out"
|
||||
trap 'rm -rf "${OUTFILE}"' EXIT
|
||||
|
||||
EXPECTED_REGEX="^.*TASK.*18236 callback task template fix OUTPUT 2"
|
||||
ansible-playbook "$@" -i ../../inventory test.yml | tee "${OUTFILE}"
|
||||
echo "Grepping for ${EXPECTED_REGEX} in stdout."
|
||||
grep -e "${EXPECTED_REGEX}" "${OUTFILE}"
|
28
test/integration/targets/callback_retry_task_name/test.yml
Normal file
28
test/integration/targets/callback_retry_task_name/test.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- hosts: testhost
|
||||
gather_facts: False
|
||||
vars:
|
||||
foo: blippy
|
||||
tasks:
|
||||
- name: First run {{ foo }}
|
||||
command: echo "18236 callback task template fix OUTPUT 1"
|
||||
register: the_result_var
|
||||
|
||||
- block:
|
||||
- name: "{{ the_result_var.stdout }}"
|
||||
command: echo "18236 callback task template fix OUTPUT 2"
|
||||
register: the_result_var
|
||||
retries: 1
|
||||
delay: 1
|
||||
until: False
|
||||
ignore_errors: true
|
||||
|
||||
# - name: assert task_name was
|
||||
|
||||
- name: "{{ the_result_var.stdout }}"
|
||||
command: echo "18236 callback taskadfadf template fix OUTPUT 3"
|
||||
register: the_result_var
|
||||
|
||||
- name: "{{ the_result_var.stdout }}"
|
||||
debug:
|
||||
msg: "nothing to see here."
|
Loading…
Add table
Add a link
Reference in a new issue