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:
Adrian Likins 2017-02-24 12:33:24 -05:00 committed by GitHub
commit 8830cde28d
6 changed files with 56 additions and 2 deletions

View file

@ -27,7 +27,10 @@ UNAME := $(shell uname | tr '[:upper:]' '[:lower:]')
all: other non_destructive destructive
other: ansible test_test_infra parsing test_var_blending test_var_precedence unicode test_templating_settings environment test_as includes blocks pull_run pull_no_127 pull_limit_inventory check_mode test_hash test_handlers test_group_by test_vault test_tags test_lookup_paths no_log test_gathering_facts test_binary_modules_posix test_hosts_field test_lookup_properties args test_jinja2_groupby
other: ansible test_test_infra parsing test_var_blending test_var_precedence unicode test_templating_settings \
environment test_as includes blocks pull_run pull_no_127 pull_limit_inventory check_mode test_hash test_handlers \
test_group_by test_vault test_tags test_lookup_paths no_log test_gathering_facts test_binary_modules_posix \
test_hosts_field test_lookup_properties args test_jinja2_groupby test_callback_retry_task_name
ansible:
(cd targets/ansible && ./runme.sh $(TEST_FLAGS))
@ -326,3 +329,6 @@ test_lookup_properties:
args:
(cd targets/args && ./runme.sh $(TEST_FLAGS))
test_callback_retry_task_name:
(cd targets/callback_retry_task_name && ./runme.sh $(TEST_FLAGS))

View file

@ -0,0 +1 @@
posix/ci/group3

View 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}"

View 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."