diff options
author | Christian Segundo | 2023-04-20 10:24:53 +0200 |
---|---|---|
committer | Christian Segundo | 2023-04-20 10:24:53 +0200 |
commit | 23ec5073810119ac5684d1b4458ec27ed898228e (patch) | |
tree | b426bf0a9d165c0fd2eff285af344f64d5264d3b /tasks | |
download | zfs-1.0.0.tar.gz |
first commit1.0.0
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/main.yaml | 28 | ||||
-rw-r--r-- | tasks/zpool.yaml | 23 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tasks/main.yaml b/tasks/main.yaml new file mode 100644 index 0000000..207006b --- /dev/null +++ b/tasks/main.yaml @@ -0,0 +1,28 @@ +- name: Install packages + block: + - apt: + name: + - linux-headers-amd64 + - zfs-dkms + - apt: + name: zfsutils-linux + default_release: "{{ ansible_distribution_release | lower }}-backports" + +- name: Add the zfs module + community.general.modprobe: + name: zfs + state: present + +- include_tasks: zpool.yaml + loop: "{{ zpools }}" + loop_control: + loop_var: zpool + +- name: Create ZVOL + community.general.zfs: + name: "{{ zvol.pool }}/{{ zvol.name }}" + state: "{{ zvol.state }}" + extra_zfs_properties: "{{ zvol.extra_zfs_properties }}" + loop: "{{ zvols }}" + loop_control: + loop_var: zvol 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 |