aboutsummaryrefslogtreecommitdiff
path: root/tasks/zpool.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/zpool.yaml')
-rw-r--r--tasks/zpool.yaml23
1 files changed, 23 insertions, 0 deletions
diff --git a/tasks/zpool.yaml b/tasks/zpool.yaml
new file mode 100644
index 0000000..97ba8c6
--- /dev/null
+++ b/tasks/zpool.yaml
@@ -0,0 +1,23 @@
+- name: Check ZFS pool existance
+ command: zpool list -Ho name {{ zpool.name }}
+ register: result_pool_list
+ ignore_errors: true
+ changed_when: false
+
+- name: Create ZFS pool
+ command: >-
+ zpool create
+ {% if zpool.options is defined and zpool.options | length > 0 %}-o {{ zpool.options | join(' -o ') }}{% endif %}
+ {% if zpool.mountpoint %}-m {{ zpool.mountpoint }}{% endif %}
+ {{ zpool.name }}
+ {% if zpool.mode is defined %}{{ zpool.mode }}{% endif %}
+ {{ zpool.devices | join(' ') }}
+ when:
+ - zpool.state | default('present') == 'present'
+ - result_pool_list.rc == 1
+
+- name: Destroy ZFS pool
+ command: zpool destroy {{ zpool.name }}
+ when:
+ - zpool.state | default('present') == 'absent'
+ - result_pool_list.rc == 0