summaryrefslogtreecommitdiff
path: root/roles/storage/lvm/device/tasks/main.yml
blob: bac06b3de3fe5bc54d0ab6af7e2b71b80ac7a6c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
---
- name: check device parent
  when: "'parent' in lvm_device"
  assert:
    msg: "the device parent must be a lvm thinpool"
    that:
    - (lvm_device.parent.thinpool | default(false))

- name: install thin-provisioning-tools
  when: (lvm_device.thinpool | default(false))
  apt:
    name: thin-provisioning-tools
    state: present

- name: create logical volume
  lvol:
    vg: "{{ lvm_device.parent.vg | default(lvm_device.vg) }}"
    lv: "{{ (lvm_device.thinpool | default(false)) | ternary(omit, lvm_device.lv) }}"
    size: "{{ lvm_device.size }}"
    thinpool: "{{ (lvm_device.thinpool | default(false)) | ternary(lvm_device.lv, (lvm_device.parent.lv | default(omit))) }}"

- name: export device path
  when: not (lvm_device.thinpool | default(false))
  set_fact:
    storage_device_path: "/dev/mapper/{{ lvm_device.parent.vg | default(lvm_device.vg) | replace('-', '--') }}-{{ lvm_device.lv | replace('-', '--') }}"