Debian Codegraph @

test/integration/targets/warning-context/tasks/main.yml

raw
1 # Warnings and deprecations are imported into the warning context when module results are processed.
2 # These tests ensure that the warnings/deprecations are visible during task execution despite this.
3
4 - name: Emit no warning or deprecation
5 ping:
6 failed_when: _task.result.warnings | length > 0 or _task.result.deprecations | length > 0
7 register: no_warning_or_deprecation
8
9 - name: Emit a warning and deprecation
10 warning-deprecation:
11 register: unchanged
12
13 - name: Make task changed when a specific warning is visible during task execution
14 warning-deprecation:
15 changed_when: _task.result.warnings[0] == "This is a warning from a module"
16 register: warning_changed
17
18 - name: Make task changed when a specific deprecation is visible during task execution
19 warning-deprecation:
20 changed_when: _task.result.deprecations[0].msg == "This is a deprecation from a module"
21 register: deprecation_changed
22
23 - name: Make task failed when a specific warning is visible during task execution
24 warning-deprecation:
25 failed_when: _task.result.warnings[0] == "This is a warning from a module"
26 register: warning_failed
27 ignore_errors: yes
28
29 - name: Make task failed when a specific deprecation is visible during task execution
30 warning-deprecation:
31 failed_when: _task.result.deprecations[0].msg == "This is a deprecation from a module"
32 register: deprecation_failed
33 ignore_errors: yes
34
35 - name: Check task results
36 assert:
37 that:
38 - "'warnings' not in no_warning_or_deprecation"
39 - "'deprecations' not in no_warning_or_deprecation"
40 - "'warnings' in unchanged"
41 - "'deprecations' in unchanged"
42 - unchanged is not changed
43 - warning_changed is changed
44 - deprecation_changed is changed
45 - warning_failed is failed
46 - deprecation_failed is failed