Debian Codegraph @

test/integration/targets/module_tracebacks/traceback.yml

raw
1 - hosts: all
2 gather_facts: no
3 tasks:
4 - name: intentionally fail module execution with a handled exception
5 ansibull:
6 errors:
7 - one
8 - two
9 ignore_errors: yes
10 register: handled_error
11 - name: intentionally fail module execution with an unhandled handled exception
12 ansibull:
13 trigger_unhandled_exception: boom
14 ignore_errors: yes
15 register: unhandled_error
16 - name: intentionally return from module main instead of exiting
17 ansibull:
18 return_from_main: true
19 ignore_errors: yes
20 register: return_from_main
21
22 - name: check if error tracebacks are enabled
23 set_fact:
24 error_tracebacks: "{{ lookup('env', 'ANSIBLE_DISPLAY_TRACEBACK') == 'error' }}"
25
26 - name: verify exceptions were properly handled
27 assert:
28 that:
29 # NB: these are regexes- using . to avoid YAML colon escaping
30 - handled_error is failed
31 - handled_error.msg is match 'Task failed. Module failed. one. two'
32
33 - unhandled_error is failed
34 - (unhandled_error.module_stderr ~ unhandled_error.module_stdout) is search 'Die.*boom'
35
36 - return_from_main is failed
37 - return_from_main.msg is match 'Task failed. Module failed. New-style module did not handle its own exit.'
38
39 - name: verify tracebacks were captured
40 assert:
41 that:
42 - handled_error.exception is contains 'Traceback'
43 - unhandled_error.exception is contains 'Traceback'
44 when: error_tracebacks
45
46 - name: verify tracebacks were not captured
47 assert:
48 that:
49 - handled_error.exception == '(traceback unavailable)'
50 - unhandled_error.exception == '(traceback unavailable)'
51 when: not error_tracebacks