diff options
author | Christian Pointner <equinox@spreadspace.org> | 2022-01-16 01:11:39 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2022-01-16 01:11:39 +0100 |
commit | 75de595335e6ad8b3f707f13ae72f18e922b9254 (patch) | |
tree | a9b772e9ab780df64ccf7669e7b69c9a4008c4e2 /roles/storage/lvm/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/lvm/volume/tasks/main.yml')
-rw-r--r-- | roles/storage/lvm/volume/tasks/main.yml | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/roles/storage/lvm/volume/tasks/main.yml b/roles/storage/lvm/volume/tasks/main.yml index 2537c28c..166d6ff8 100644 --- a/roles/storage/lvm/volume/tasks/main.yml +++ b/roles/storage/lvm/volume/tasks/main.yml @@ -1,26 +1,44 @@ --- +- name: check volume parent + when: "'parent' in lvm_volume" + assert: + msg: "the volume parent must be a lvm thinpool" + that: + - lvm_volume.parent.type == 'lvm' + - (lvm_volume.parent.thinpool | default(false)) + +- name: install thin-provisioning-tools + when: (lvm_volume.thinpool | default(false)) + apt: + name: thin-provisioning-tools + state: present + - name: create logical volume lvol: - vg: "{{ lvm_volume.vg }}" - lv: "{{ lvm_volume.lv }}" + vg: "{{ lvm_volume.parent.vg | default(lvm_volume.vg) }}" + lv: "{{ (lvm_volume.thinpool | default(false)) | ternary(omit, lvm_volume.lv) }}" size: "{{ lvm_volume.size }}" + thinpool: "{{ (lvm_volume.thinpool | default(false)) | ternary(lvm_volume.lv, (lvm_volume.parent.lv | default(omit))) }}" -- name: create filesystem - filesystem: - fstype: "{{ lvm_volume.fs }}" - dev: "/dev/mapper/{{ lvm_volume.vg | replace('-', '--') }}-{{ lvm_volume.lv | replace('-', '--') }}" +- name: create and mount filesystem + when: not (lvm_volume.thinpool | default(false)) + block: + - name: create filesystem + filesystem: + fstype: "{{ lvm_volume.fs }}" + dev: "/dev/mapper/{{ lvm_volume.parent.vg | default(lvm_volume.vg) | replace('-', '--') }}-{{ lvm_volume.lv | replace('-', '--') }}" -- name: mount filesytem - mount: - src: "/dev/mapper/{{ lvm_volume.vg | replace('-', '--') }}-{{ lvm_volume.lv | replace('-', '--') }}" - path: "{{ lvm_volume.dest }}" - fstype: "{{ lvm_volume.fs }}" - state: mounted + - name: mount filesytem + mount: + src: "/dev/mapper/{{ lvm_volume.parent.vg | default(lvm_volume.vg) | replace('-', '--') }}-{{ lvm_volume.lv | replace('-', '--') }}" + path: "{{ lvm_volume.dest }}" + fstype: "{{ lvm_volume.fs }}" + state: mounted -- name: set volume owner/group and mode - file: - state: directory - path: "{{ lvm_volume.dest }}" - mode: "{{ lvm_volume.mode | default(omit) }}" - owner: "{{ lvm_volume.owner | default(omit) }}" - group: "{{ lvm_volume.group | default(omit) }}" + - name: set volume owner/group and mode + file: + state: directory + path: "{{ lvm_volume.dest }}" + mode: "{{ lvm_volume.mode | default(omit) }}" + owner: "{{ lvm_volume.owner | default(omit) }}" + group: "{{ lvm_volume.group | default(omit) }}" |