| 1 |
--- |
| 2 |
# Copyright (c) 2025, Tom Hesse <[email protected]> |
| 3 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
- name: Test single disk pool creation |
| 7 |
block: |
| 8 |
- name: Ensure single disk pool exists |
| 9 |
community.general.zpool: |
| 10 |
name: "{{ zpool_single_disk_pool_name }}" |
| 11 |
vdevs: |
| 12 |
- disks: "{{ zpool_single_disk_config }}" |
| 13 |
|
| 14 |
- name: Check if single disk pool exists |
| 15 |
ansible.builtin.command: |
| 16 |
cmd: "zpool list -H -o name,health {{ zpool_single_disk_pool_name }}" |
| 17 |
register: single_disk_pool_check |
| 18 |
changed_when: false |
| 19 |
|
| 20 |
- name: Assert that single disk pool is online |
| 21 |
ansible.builtin.assert: |
| 22 |
that: |
| 23 |
- "zpool_single_disk_pool_name in single_disk_pool_check.stdout" |
| 24 |
- "'ONLINE' in single_disk_pool_check.stdout" |
| 25 |
|
| 26 |
- name: Test mirror disk pool creation |
| 27 |
block: |
| 28 |
- name: Ensure mirror disk pool exists |
| 29 |
community.general.zpool: |
| 30 |
name: "{{ zpool_mirror_disk_pool_name }}" |
| 31 |
vdevs: |
| 32 |
- type: mirror |
| 33 |
disks: "{{ zpool_mirror_disk_config }}" |
| 34 |
|
| 35 |
- name: Check if mirror disk pool exists |
| 36 |
ansible.builtin.command: |
| 37 |
cmd: "zpool list -H -o name,health {{ zpool_mirror_disk_pool_name }}" |
| 38 |
register: mirror_disk_pool_check |
| 39 |
changed_when: false |
| 40 |
|
| 41 |
- name: Assert that mirror disk pool is online |
| 42 |
ansible.builtin.assert: |
| 43 |
that: |
| 44 |
- "zpool_mirror_disk_pool_name in mirror_disk_pool_check.stdout" |
| 45 |
- "'ONLINE' in mirror_disk_pool_check.stdout" |
| 46 |
|
| 47 |
- name: Test raidz disk pool creation |
| 48 |
block: |
| 49 |
- name: Ensure raidz disk pool exists |
| 50 |
community.general.zpool: |
| 51 |
name: "{{ zpool_raidz_disk_pool_name }}" |
| 52 |
vdevs: |
| 53 |
- type: raidz |
| 54 |
disks: "{{ zpool_raidz_disk_config }}" |
| 55 |
|
| 56 |
- name: Check if raidz disk pool exists |
| 57 |
ansible.builtin.command: |
| 58 |
cmd: "zpool list -H -o name,health {{ zpool_raidz_disk_pool_name }}" |
| 59 |
register: raidz_disk_pool_check |
| 60 |
changed_when: false |
| 61 |
|
| 62 |
- name: Assert that raidz disk pool is online |
| 63 |
ansible.builtin.assert: |
| 64 |
that: |
| 65 |
- "zpool_raidz_disk_pool_name in raidz_disk_pool_check.stdout" |
| 66 |
- "'ONLINE' in raidz_disk_pool_check.stdout" |
| 67 |
|
| 68 |
- name: Test single disk pool deletion |
| 69 |
block: |
| 70 |
- name: Ensure single disk pool is absent |
| 71 |
community.general.zpool: |
| 72 |
name: "{{ zpool_single_disk_pool_name }}" |
| 73 |
state: absent |
| 74 |
|
| 75 |
- name: Check if single disk pool is absent |
| 76 |
ansible.builtin.command: |
| 77 |
cmd: "zpool list -H -o name,health {{ zpool_single_disk_pool_name }}" |
| 78 |
register: single_disk_pool_check |
| 79 |
ignore_errors: true |
| 80 |
changed_when: false |
| 81 |
|
| 82 |
- name: Assert that single disk pool is online |
| 83 |
ansible.builtin.assert: |
| 84 |
that: |
| 85 |
- "'no such pool' in single_disk_pool_check.stderr" |
| 86 |
|
| 87 |
- name: Test mirror disk pool deletion |
| 88 |
block: |
| 89 |
- name: Ensure mirror disk pool is absent |
| 90 |
community.general.zpool: |
| 91 |
name: "{{ zpool_mirror_disk_pool_name }}" |
| 92 |
state: absent |
| 93 |
|
| 94 |
- name: Check if mirror disk pool is absent |
| 95 |
ansible.builtin.command: |
| 96 |
cmd: "zpool list -H -o name,health {{ zpool_mirror_disk_pool_name }}" |
| 97 |
register: mirror_disk_pool_check |
| 98 |
ignore_errors: true |
| 99 |
changed_when: false |
| 100 |
|
| 101 |
- name: Assert that mirror disk pool is online |
| 102 |
ansible.builtin.assert: |
| 103 |
that: |
| 104 |
- "'no such pool' in mirror_disk_pool_check.stderr" |
| 105 |
|
| 106 |
- name: Test raidz disk pool deletion |
| 107 |
block: |
| 108 |
- name: Ensure raidz disk pool is absent |
| 109 |
community.general.zpool: |
| 110 |
name: "{{ zpool_raidz_disk_pool_name }}" |
| 111 |
state: absent |
| 112 |
|
| 113 |
- name: Check if raidz disk pool is absent |
| 114 |
ansible.builtin.command: |
| 115 |
cmd: "zpool list -H -o name,health {{ zpool_raidz_disk_pool_name }}" |
| 116 |
register: raidz_disk_pool_check |
| 117 |
ignore_errors: true |
| 118 |
changed_when: false |
| 119 |
|
| 120 |
- name: Assert that raidz disk pool is online |
| 121 |
ansible.builtin.assert: |
| 122 |
that: |
| 123 |
- "'no such pool' in raidz_disk_pool_check.stderr" |