summaryrefslogtreecommitdiff
path: root/roles/storage/zfs/volume/tasks/main.yml
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-01-16 01:11:39 +0100
committerChristian Pointner <equinox@spreadspace.org>2022-01-16 01:11:39 +0100
commit75de595335e6ad8b3f707f13ae72f18e922b9254 (patch)
treea9b772e9ab780df64ccf7669e7b69c9a4008c4e2 /roles/storage/zfs/volume/tasks/main.yml
parent(zfs|lvm)/volume: add handling of owner/group and permissions (diff)
storage/volumes: support nesting
Diffstat (limited to 'roles/storage/zfs/volume/tasks/main.yml')
-rw-r--r--roles/storage/zfs/volume/tasks/main.yml23
1 files changed, 17 insertions, 6 deletions
diff --git a/roles/storage/zfs/volume/tasks/main.yml b/roles/storage/zfs/volume/tasks/main.yml
index 1bd198bb..0dc0e82d 100644
--- a/roles/storage/zfs/volume/tasks/main.yml
+++ b/roles/storage/zfs/volume/tasks/main.yml
@@ -1,18 +1,29 @@
---
+ ## TODO: implement recursive nesting
+- name: check volume parent
+ when: "'parent' in zfs_volume"
+ assert:
+ msg: "the volume parent must be of type zfs and must not have a parent"
+ that:
+ - zfs_volume.parent.type == 'zfs'
+ - "'parent' not in zfs_volume.parent"
+
- name: create zfs dataset
zfs:
- name: "{{ zfs_volume.pool }}/{{ zfs_volume.name }}"
+ name: "{{ ('parent' in zfs_volume) | ternary((zfs_volume.parent.pool | default(''))~'/'~(zfs_volume.parent.name | default('')), zfs_volume.pool) }}/{{ zfs_volume.name }}"
extra_zfs_properties: "{{ zfs_volume.properties | dehumanize_zfs_properties | default(omit) }}"
state: present
+- name: compute derivated mountpoint
+ set_fact:
+ zfs_volume_mountpoint: "{{ (zfs_pools[zfs_volume.parent.pool | default(zfs_volume.pool)].mountpoint, ('parent' in zfs_volume) | ternary((zfs_volume.parent.name | default('')), ''), zfs_volume.name) | path_join }}"
+
- name: bind mount filesystem
- vars:
- zfs_mountpoint: "{{ (zfs_pools[zfs_volume.pool].mountpoint, zfs_volume.name) | path_join }}"
when:
- "'dest' in zfs_volume"
- - zfs_volume.dest != zfs_mountpoint
+ - zfs_volume.dest != zfs_volume_mountpoint
mount:
- src: "{{ zfs_mountpoint }}"
+ src: "{{ zfs_volume_mountpoint }}"
path: "{{ zfs_volume.dest }}"
fstype: none
opts: bind,x-systemd.automount,nofail
@@ -21,7 +32,7 @@
- name: set volume owner/group and mode
file:
state: directory
- path: "{{ zfs_volume.dest | default((zfs_pools[zfs_volume.pool].mountpoint, zfs_volume.name) | path_join) }}"
+ path: "{{ zfs_volume.dest | default(zfs_volume_mountpoint) }}"
mode: "{{ zfs_volume.mode | default(omit) }}"
owner: "{{ zfs_volume.owner | default(omit) }}"
group: "{{ zfs_volume.group | default(omit) }}"