|
73 | 73 | include_role: |
74 | 74 | name: storage |
75 | 75 | vars: |
76 | | - storage_safe_mode: true |
77 | 76 | storage_volumes: |
78 | 77 | - name: test1 |
79 | 78 | type: disk |
|
101 | 100 | not blivet_output.changed" |
102 | 101 | msg: "Unexpected behavior w/ existing data on specified disks" |
103 | 102 |
|
| 103 | + - name: Unmount file system |
| 104 | + include_role: |
| 105 | + name: storage |
| 106 | + vars: |
| 107 | + storage_volumes: |
| 108 | + - name: test1 |
| 109 | + type: disk |
| 110 | + fs_type: 'ext4' |
| 111 | + disks: "{{ unused_disks }}" |
| 112 | + mount_point: none |
| 113 | + |
| 114 | + - name: Test for correct handling of safe_mode with unmounted filesystem |
| 115 | + block: |
| 116 | + - name: Try to replace the file system on disk in safe mode |
| 117 | + include_role: |
| 118 | + name: storage |
| 119 | + vars: |
| 120 | + storage_volumes: |
| 121 | + - name: test1 |
| 122 | + type: disk |
| 123 | + fs_type: 'ext3' |
| 124 | + disks: "{{ unused_disks }}" |
| 125 | + |
| 126 | + - name: UNREACH |
| 127 | + fail: |
| 128 | + msg: "this should be unreachable" |
| 129 | + |
| 130 | + rescue: |
| 131 | + - name: Check that we failed in the role |
| 132 | + assert: |
| 133 | + that: |
| 134 | + - ansible_failed_task.name != 'UNREACH' |
| 135 | + msg: "Role has not failed when it should have" |
| 136 | + vars: |
| 137 | + # Ugh! needed to expand ansible_failed_task |
| 138 | + storage_provider: blivet |
| 139 | + |
| 140 | + - name: Verify the output |
| 141 | + assert: |
| 142 | + that: "blivet_output.failed and |
| 143 | + blivet_output.msg|regex_search('cannot remove existing formatting on volume.*in safe mode') and |
| 144 | + not blivet_output.changed" |
| 145 | + msg: "Unexpected behavior w/ existing data on specified disks" |
| 146 | + |
| 147 | + - name: Remount file system |
| 148 | + include_role: |
| 149 | + name: storage |
| 150 | + vars: |
| 151 | + storage_volumes: |
| 152 | + - name: test1 |
| 153 | + type: disk |
| 154 | + fs_type: 'ext4' |
| 155 | + disks: "{{ unused_disks }}" |
| 156 | + mount_point: "{{ mount_location }}" |
| 157 | + |
104 | 158 | - name: stat the file |
105 | 159 | stat: |
106 | 160 | path: "{{ testfile }}" |
|
118 | 172 | include_role: |
119 | 173 | name: storage |
120 | 174 | vars: |
121 | | - storage_safe_mode: true |
122 | 175 | storage_pools: |
123 | 176 | - name: foo |
124 | 177 | disks: "{{ unused_disks }}" |
|
145 | 198 | not blivet_output.changed" |
146 | 199 | msg: "Unexpected behavior w/ existing data on specified disks" |
147 | 200 |
|
| 201 | + - name: Test for correct handling of safe_mode with existing filesystem |
| 202 | + block: |
| 203 | + - name: Try to create LVM pool on disk that already belongs to an existing filesystem |
| 204 | + include_role: |
| 205 | + name: storage |
| 206 | + vars: |
| 207 | + storage_pools: |
| 208 | + - name: foo |
| 209 | + disks: "{{ unused_disks }}" |
| 210 | + type: lvm |
| 211 | + |
| 212 | + - name: UNREACH |
| 213 | + fail: |
| 214 | + msg: "this should be unreachable" |
| 215 | + |
| 216 | + rescue: |
| 217 | + - name: Check that we failed in the role |
| 218 | + assert: |
| 219 | + that: |
| 220 | + - ansible_failed_task.name != 'UNREACH' |
| 221 | + msg: "Role has not failed when it should have" |
| 222 | + vars: |
| 223 | + # Ugh! needed to expand ansible_failed_task |
| 224 | + storage_provider: blivet |
| 225 | + |
| 226 | + - name: Verify the output |
| 227 | + assert: |
| 228 | + that: "{{ blivet_output.failed and |
| 229 | + blivet_output.msg|regex_search('cannot remove existing formatting and/or devices on disk.*in safe mode') and |
| 230 | + not blivet_output.changed }}" |
| 231 | + msg: "Unexpected behavior w/ existing data on specified disks" |
| 232 | + |
148 | 233 | - name: stat the file |
149 | 234 | stat: |
150 | 235 | path: "{{ testfile }}" |
|
169 | 254 | - name: Verify the output |
170 | 255 | assert: |
171 | 256 | that: not blivet_output.failed |
172 | | - msg: "failed to create partition pool over existing file system using default value of safe_mode" |
| 257 | + msg: "failed to create partition pool over existing file system w/o safe_mode" |
173 | 258 |
|
174 | 259 | - name: Clean up |
175 | 260 | include_role: |
176 | 261 | name: storage |
177 | 262 | vars: |
178 | 263 | storage_safe_mode: false |
179 | | - storage_volumes: |
180 | | - - name: test1 |
181 | | - type: disk |
| 264 | + storage_pools: |
| 265 | + - name: foo |
| 266 | + type: partition |
182 | 267 | disks: "{{ unused_disks }}" |
183 | | - present: false |
| 268 | + state: absent |
0 commit comments