|
1 | 1 | - hosts: all |
| 2 | + become: true |
2 | 3 | vars: |
| 4 | + storage_safe_mode: false |
3 | 5 | mount_location: '/opt/test1' |
4 | 6 | volume_group_size: '10g' |
5 | 7 | volume_size_before: '5g' |
6 | 8 | volume_size_after: '9g' |
| 9 | + invalid_size1: 'xyz GiB' |
| 10 | + invalid_size2: 'none' |
| 11 | + unused_disk_subfact: '{{ ansible_devices[unused_disks[0]] }}' |
| 12 | + too_large_size: '{{ (unused_disk_subfact.sectors|int + 1) * |
| 13 | + unused_disk_subfact.sectorsize|int }}' |
| 14 | + disk_size: '{{ unused_disk_subfact.sectors|int * |
| 15 | + unused_disk_subfact.sectorsize|int }}' |
7 | 16 |
|
8 | 17 | tasks: |
9 | 18 | - include_role: |
|
14 | 23 | min_size: "{{ volume_group_size }}" |
15 | 24 | max_return: 1 |
16 | 25 |
|
| 26 | + # For ext4 FS |
| 27 | + |
17 | 28 | - name: Create one LVM logical volume with "{{ volume_size_before }}" under one volume group |
18 | 29 | include_role: |
19 | 30 | name: storage |
|
47 | 58 |
|
48 | 59 | - include_tasks: verify-role-results.yml |
49 | 60 |
|
| 61 | + - name: Change volume size to "{{ volume_size_before }}" |
| 62 | + include_role: |
| 63 | + name: storage |
| 64 | + vars: |
| 65 | + storage_pools: |
| 66 | + - name: foo |
| 67 | + type: lvm |
| 68 | + disks: "{{ unused_disks }}" |
| 69 | + volumes: |
| 70 | + - name: test1 |
| 71 | + fs_type: 'ext4' |
| 72 | + size: "{{ volume_size_before }}" |
| 73 | + mount_point: "{{ mount_location }}" |
| 74 | + |
| 75 | + - include_tasks: verify-role-results.yml |
| 76 | + |
| 77 | + - name: Test for correct handling of too-large volume size |
| 78 | + block: |
| 79 | + - name: Try to create LVM with a too-large volume size, resize to "{{ too_large_size }}" |
| 80 | + include_role: |
| 81 | + name: storage |
| 82 | + vars: |
| 83 | + storage_pools: |
| 84 | + - name: foo |
| 85 | + disks: "{{ unused_disks }}" |
| 86 | + volumes: |
| 87 | + - name: test1 |
| 88 | + fs_type: 'ext4' |
| 89 | + size: "{{ too_large_size }}" |
| 90 | + mount_point: "{{ mount_location }}" |
| 91 | + |
| 92 | + - name: Unreachable task |
| 93 | + fail: |
| 94 | + msg: UNREACH |
| 95 | + |
| 96 | + rescue: |
| 97 | + - name: Check that we failed in the role |
| 98 | + assert: |
| 99 | + that: |
| 100 | + - ansible_failed_result.msg != 'UNREACH' |
| 101 | + msg: "Role has not failed when it should have" |
| 102 | + |
| 103 | + - name: Verify the output |
| 104 | + assert: |
| 105 | + that: "blivet_output.failed and |
| 106 | + blivet_output.msg|regex_search('volume.+cannot be resized to.+') and |
| 107 | + not blivet_output.changed" |
| 108 | + msg: "Unexpected behavior w/ invalid volume size" |
| 109 | + |
| 110 | + - name: Test for correct handling of volume size equal disk's size |
| 111 | + block: |
| 112 | + - name: Try to create LVM with volume size equal disk's size, resize to "{{ disk_size }}" |
| 113 | + include_role: |
| 114 | + name: storage |
| 115 | + vars: |
| 116 | + storage_pools: |
| 117 | + - name: foo |
| 118 | + disks: "{{ unused_disks }}" |
| 119 | + volumes: |
| 120 | + - name: test1 |
| 121 | + fs_type: 'ext4' |
| 122 | + size: "{{ disk_size }}" |
| 123 | + mount_point: "{{ mount_location }}" |
| 124 | + |
| 125 | + - name: Unreachable task |
| 126 | + fail: |
| 127 | + msg: UNREACH |
| 128 | + |
| 129 | + rescue: |
| 130 | + - name: Check that we failed in the role |
| 131 | + assert: |
| 132 | + that: |
| 133 | + - ansible_failed_result.msg != 'UNREACH' |
| 134 | + msg: "Role has not failed when it should have" |
| 135 | + |
| 136 | + - name: Verify the output |
| 137 | + assert: |
| 138 | + that: "blivet_output.failed and |
| 139 | + blivet_output.msg|regex_search('volume.+cannot be resized to.+') and |
| 140 | + not blivet_output.changed" |
| 141 | + msg: "Unexpected behavior w/ invalid volume size" |
| 142 | + |
| 143 | + - name: Test for correct handling of invalid size specification |
| 144 | + block: |
| 145 | + - name: Try to create LVM with an invalid size specification, resize to "{{ invalid_size1 }}" |
| 146 | + include_role: |
| 147 | + name: storage |
| 148 | + vars: |
| 149 | + storage_pools: |
| 150 | + - name: foo |
| 151 | + disks: "{{ unused_disks }}" |
| 152 | + volumes: |
| 153 | + - name: test1 |
| 154 | + fs_type: 'ext4' |
| 155 | + size: "{{ invalid_size1 }}" |
| 156 | + mount_point: "{{ mount_location }}" |
| 157 | + |
| 158 | + - name: Unreachable task |
| 159 | + fail: |
| 160 | + msg: UNREACH |
| 161 | + |
| 162 | + rescue: |
| 163 | + - name: Check that we failed in the role |
| 164 | + assert: |
| 165 | + that: |
| 166 | + - ansible_failed_result.msg != 'UNREACH' |
| 167 | + msg: "Role has not failed when it should have" |
| 168 | + |
| 169 | + - name: Verify the output |
| 170 | + assert: |
| 171 | + that: "blivet_output.failed and |
| 172 | + blivet_output.msg|regex_search('invalid size.+for volume') and |
| 173 | + not blivet_output.changed" |
| 174 | + msg: "Unexpected behavior w/ invalid volume size" |
| 175 | + |
| 176 | + - name: Test for correct handling of invalid size specification |
| 177 | + block: |
| 178 | + - name: Try to create LVM with an invalid size specification, resize to "{{ invalid_size2 }}" |
| 179 | + include_role: |
| 180 | + name: storage |
| 181 | + vars: |
| 182 | + storage_pools: |
| 183 | + - name: foo |
| 184 | + disks: "{{ unused_disks }}" |
| 185 | + volumes: |
| 186 | + - name: test1 |
| 187 | + fs_type: 'ext4' |
| 188 | + size: "{{ invalid_size2 }}" |
| 189 | + mount_point: "{{ mount_location }}" |
| 190 | + |
| 191 | + - name: Unreachable task |
| 192 | + fail: |
| 193 | + msg: UNREACH |
| 194 | + |
| 195 | + rescue: |
| 196 | + - name: Check that we failed in the role |
| 197 | + assert: |
| 198 | + that: |
| 199 | + - ansible_failed_result.msg != 'UNREACH' |
| 200 | + msg: "Role has not failed when it should have" |
| 201 | + |
| 202 | + - name: Verify the output |
| 203 | + assert: |
| 204 | + that: "blivet_output.failed and |
| 205 | + blivet_output.msg|regex_search('invalid size.+for volume') and |
| 206 | + not blivet_output.changed" |
| 207 | + msg: "Unexpected behavior w/ invalid volume size" |
| 208 | + |
50 | 209 | - name: Clean up |
51 | 210 | include_role: |
52 | 211 | name: storage |
|
57 | 216 | state: absent |
58 | 217 | volumes: |
59 | 218 | - name: test1 |
60 | | - size: "{{ volume_size_after }}" |
| 219 | + size: "{{ volume_size_before }}" |
| 220 | + mount_point: "{{ mount_location }}" |
| 221 | + |
| 222 | + - include_tasks: verify-role-results.yml |
| 223 | + |
| 224 | + # For ext3 FS |
| 225 | + |
| 226 | + - name: Create a LVM logical volume with "{{ volume_size_before }}" for ext3 FS |
| 227 | + include_role: |
| 228 | + name: storage |
| 229 | + vars: |
| 230 | + storage_pools: |
| 231 | + - name: foo |
| 232 | + type: lvm |
| 233 | + disks: "{{ unused_disks }}" |
| 234 | + volumes: |
| 235 | + - name: test1 |
| 236 | + fs_type: 'ext3' |
| 237 | + size: "{{ volume_size_before }}" |
| 238 | + mount_point: "{{ mount_location }}" |
| 239 | + |
| 240 | + - include_tasks: verify-role-results.yml |
| 241 | + |
| 242 | + - name: Change volume size to "{{ volume_size_after }}" |
| 243 | + include_role: |
| 244 | + name: storage |
| 245 | + vars: |
| 246 | + storage_pools: |
| 247 | + - name: foo |
| 248 | + type: lvm |
| 249 | + disks: "{{ unused_disks }}" |
| 250 | + volumes: |
| 251 | + - name: test1 |
| 252 | + fs_type: 'ext3' |
| 253 | + size: "{{ volume_size_after }}" |
| 254 | + mount_point: "{{ mount_location }}" |
| 255 | + |
| 256 | + - include_tasks: verify-role-results.yml |
| 257 | + |
| 258 | + - name: Change volume size to "{{ volume_size_before }}" |
| 259 | + include_role: |
| 260 | + name: storage |
| 261 | + vars: |
| 262 | + storage_pools: |
| 263 | + - name: foo |
| 264 | + type: lvm |
| 265 | + disks: "{{ unused_disks }}" |
| 266 | + volumes: |
| 267 | + - name: test1 |
| 268 | + fs_type: 'ext3' |
| 269 | + size: "{{ volume_size_before }}" |
| 270 | + mount_point: "{{ mount_location }}" |
| 271 | + |
| 272 | + - include_tasks: verify-role-results.yml |
| 273 | + |
| 274 | + - name: Clean up |
| 275 | + include_role: |
| 276 | + name: storage |
| 277 | + vars: |
| 278 | + storage_pools: |
| 279 | + - name: foo |
| 280 | + disks: "{{ unused_disks }}" |
| 281 | + state: absent |
| 282 | + volumes: |
| 283 | + - name: test1 |
| 284 | + size: "{{ volume_size_before }}" |
| 285 | + mount_point: "{{ mount_location }}" |
| 286 | + |
| 287 | + - include_tasks: verify-role-results.yml |
| 288 | + |
| 289 | + # For ext2 FS |
| 290 | + |
| 291 | + - name: Create a LVM logical volume with "{{ volume_size_before }}" for ext2 FS |
| 292 | + include_role: |
| 293 | + name: storage |
| 294 | + vars: |
| 295 | + storage_pools: |
| 296 | + - name: foo |
| 297 | + type: lvm |
| 298 | + disks: "{{ unused_disks }}" |
| 299 | + volumes: |
| 300 | + - name: test1 |
| 301 | + fs_type: 'ext2' |
| 302 | + size: "{{ volume_size_before }}" |
| 303 | + mount_point: "{{ mount_location }}" |
| 304 | + |
| 305 | + - include_tasks: verify-role-results.yml |
| 306 | + |
| 307 | + - name: Change volume size to "{{ volume_size_after }}" |
| 308 | + include_role: |
| 309 | + name: storage |
| 310 | + vars: |
| 311 | + storage_pools: |
| 312 | + - name: foo |
| 313 | + type: lvm |
| 314 | + disks: "{{ unused_disks }}" |
| 315 | + volumes: |
| 316 | + - name: test1 |
| 317 | + fs_type: 'ext2' |
| 318 | + size: "{{ volume_size_after }}" |
| 319 | + mount_point: "{{ mount_location }}" |
| 320 | + |
| 321 | + - include_tasks: verify-role-results.yml |
| 322 | + |
| 323 | + - name: Change volume size to "{{ volume_size_before }}" |
| 324 | + include_role: |
| 325 | + name: storage |
| 326 | + vars: |
| 327 | + storage_pools: |
| 328 | + - name: foo |
| 329 | + type: lvm |
| 330 | + disks: "{{ unused_disks }}" |
| 331 | + volumes: |
| 332 | + - name: test1 |
| 333 | + fs_type: 'ext2' |
| 334 | + size: "{{ volume_size_before }}" |
| 335 | + mount_point: "{{ mount_location }}" |
| 336 | + |
| 337 | + - include_tasks: verify-role-results.yml |
| 338 | + |
| 339 | + - name: Clean up |
| 340 | + include_role: |
| 341 | + name: storage |
| 342 | + vars: |
| 343 | + storage_pools: |
| 344 | + - name: foo |
| 345 | + disks: "{{ unused_disks }}" |
| 346 | + state: absent |
| 347 | + volumes: |
| 348 | + - name: test1 |
| 349 | + size: "{{ volume_size_before }}" |
61 | 350 | mount_point: "{{ mount_location }}" |
62 | 351 |
|
63 | 352 | - include_tasks: verify-role-results.yml |
0 commit comments