mirror of https://github.com/ansible/ansible.git
default callback - add "show_task_path_on_failure" option (#73260)
When running in verbosity <2, display the file and line number for tasks that fail. This provides useful information without having to run at increased verbosity. * Move _print_task_path to CallbackBase class * Add integration tests * Add color parameter to _print_task_path() * Keep color output consistent for now Currently the path is display with COLOR_DEBUG formatting with verbosity >= 2. Instead of the color of the path changing based on verbosity level, just keep it at the currently behavior of COLOR_DEBUG. Having the color of the same information change based on verbosity level seems incorrect and makes visual parsing of the information more difficult. Co-authored-by: tahar.jegham <jeghamseifeddine@gmail.com>pull/73545/head
parent
ca448f7c35
commit
7d18ea5e93
@ -0,0 +1,5 @@
|
||||
minor_changes:
|
||||
- >-
|
||||
default callback - add ``show_task_path_on_failure`` option to display file and
|
||||
line number of tasks only on failed tasks when running at
|
||||
normal verbosity level (https://github.com/ansible/ansible/issues/64625)
|
@ -0,0 +1,2 @@
|
||||
+ ansible-playbook -i inventory test.yml
|
||||
++ set +x
|
@ -0,0 +1,100 @@
|
||||
|
||||
PLAY [testhost] ****************************************************************
|
||||
|
||||
TASK [Changed task] ************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Ok task] *****************************************************************
|
||||
ok: [testhost]
|
||||
|
||||
TASK [Failed task] *************************************************************
|
||||
task path: TEST_PATH/test.yml:16
|
||||
fatal: [testhost]: FAILED! => {"changed": false, "msg": "no reason"}
|
||||
...ignoring
|
||||
|
||||
TASK [Skipped task] ************************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Task with var in name (foo bar)] *****************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Loop task] ***************************************************************
|
||||
changed: [testhost] => (item=foo-1)
|
||||
changed: [testhost] => (item=foo-2)
|
||||
changed: [testhost] => (item=foo-3)
|
||||
|
||||
TASK [debug loop] **************************************************************
|
||||
changed: [testhost] => (item=debug-1) => {
|
||||
"msg": "debug-1"
|
||||
}
|
||||
failed: [testhost] (item=debug-2) => {
|
||||
"msg": "debug-2"
|
||||
}
|
||||
ok: [testhost] => (item=debug-3) => {
|
||||
"msg": "debug-3"
|
||||
}
|
||||
skipping: [testhost] => (item=debug-4)
|
||||
task path: TEST_PATH/test.yml:38
|
||||
fatal: [testhost]: FAILED! => {"msg": "One or more items failed"}
|
||||
...ignoring
|
||||
|
||||
TASK [EXPECTED FAILURE Failed task to be rescued] ******************************
|
||||
task path: TEST_PATH/test.yml:54
|
||||
fatal: [testhost]: FAILED! => {"changed": false, "msg": "Failed as requested from task"}
|
||||
|
||||
TASK [Rescue task] *************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [include_tasks] ***********************************************************
|
||||
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"item": 1
|
||||
}
|
||||
|
||||
TASK [copy] ********************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [replace] *****************************************************************
|
||||
--- before: .../test_diff.txt
|
||||
+++ after: .../test_diff.txt
|
||||
@@ -1 +1 @@
|
||||
-foo
|
||||
\ No newline at end of file
|
||||
+bar
|
||||
\ No newline at end of file
|
||||
|
||||
changed: [testhost]
|
||||
|
||||
TASK [replace] *****************************************************************
|
||||
ok: [testhost]
|
||||
|
||||
RUNNING HANDLER [Test handler 1] ***********************************************
|
||||
changed: [testhost]
|
||||
|
||||
RUNNING HANDLER [Test handler 2] ***********************************************
|
||||
ok: [testhost]
|
||||
|
||||
RUNNING HANDLER [Test handler 3] ***********************************************
|
||||
changed: [testhost]
|
||||
|
||||
PLAY [testhost] ****************************************************************
|
||||
|
||||
TASK [First free task] *********************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Second free task] ********************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Include some tasks] ******************************************************
|
||||
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"item": 1
|
||||
}
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
testhost : ok=19 changed=11 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2
|
||||
|
Loading…
Reference in New Issue