blob: 166d6ff81e368d5ec2c01351de029756b9e9a6b4 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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.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 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.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) }}"
|