Debian Codegraph @

test/integration/targets/failed_when/tasks/main.yml

raw
1 # Test code for failed_when.
2 # (c) 2014, Richard Isaacson <[email protected]>
3
4 # This file is part of Ansible
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18
19 - name: command rc 0 failed_when_result undef
20 shell: exit 0
21 ignore_errors: True
22 register: result
23
24 - assert:
25 that:
26 - "'failed' in result and not result.failed"
27 - result.exception is undefined
28 - result.failed_when_suppressed_exception is undefined
29
30 - name: command rc 0 failed_when_result False
31 shell: exit 0
32 failed_when: false
33 ignore_errors: true
34 register: result
35
36 - assert:
37 that:
38 - "'failed' in result and not result.failed"
39 - "'failed_when_result' in result and not result.failed_when_result"
40 - result.exception is undefined
41 - result.failed_when_suppressed_exception is undefined
42
43 - name: command rc 1 failed_when_result True
44 shell: exit 1
45 failed_when: true
46 ignore_errors: true
47 register: result
48
49 - debug:
50 var: result
51
52 - assert:
53 that:
54 - result.failed
55 - result.failed_when_result
56 - result.exception is defined
57 - result.failed_when_suppressed_exception is defined
58
59 - name: command rc 1 failed_when_result undef
60 shell: exit 1
61 ignore_errors: true
62 register: result
63
64 - assert:
65 that:
66 - "'failed' in result and result.failed"
67 - result.exception is defined
68 - result.failed_when_suppressed_exception is undefined
69
70 - name: command rc 1 failed_when_result False
71 shell: exit 1
72 failed_when: false
73 ignore_errors: true
74 register: result
75
76 - debug:
77 var: result
78
79 - assert:
80 that:
81 - "'failed' in result and not result.failed"
82 - "'failed_when_result' in result and not result.failed_when_result"
83 - result.exception is undefined
84 - result.failed_when_suppressed_exception is defined
85
86 - name: invalid conditional
87 command: echo foo
88 failed_when: boomboomboom
89 register: invalid_conditional
90 ignore_errors: true
91
92 - assert:
93 that:
94 - invalid_conditional is failed
95 - invalid_conditional.stdout is defined
96 - invalid_conditional.failed_when_result is contains('boomboomboom')
97
98 - name: add_host failed_when (coverage exercise for strategy)
99 add_host:
100 name: some_host
101 groups: blah
102 failed_when: false