-
Notifications
You must be signed in to change notification settings - Fork 98
/
exercise153.yaml
47 lines (47 loc) · 1.21 KB
/
exercise153.yaml
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
45
46
47
---
- name: set up hosts that have an sdb device
hosts: all
tasks:
- name: getting out with a nice failure message if there is no second disk
fail:
msg: there is no second disk
when: ansible_facts['devices']['sdb'] is not defined
- name: create a partition
parted:
device: /dev/sdb
number: 1
state: present
- name: create a volume group
lvg:
pvs: /dev/sdb1
vg: vgfiles
- name: run the setup module so that we can use updated facts
setup:
- name: get vg size and convert to integer in new variable
set_fact:
vgsize: "{{ ansible_facts['lvm']['vgs']['vgfiles']['size_g'] | int }}"
- name: show vgsize value
debug:
var: "{{ vgsize }}"
- name: create an LVM on big volume groups
lvol:
vg: vgfiles
lv: lvfiles
size: 6g
when: vgsize | int > 5
- name: create an LVM on small volume groups
lvol:
vg: vgfiles
lv: lvfiles
size: 3g
when: vgsize | int <= 5
- name: formatting the XFS filesystem
filesystem:
dev: /dev/vgfiles/lvfiles
fstype: xfs
- name: mounting /dev/vgfile/lvfiles
mount:
path: /files
state: mounted
src: /dev/vgfiles/lvfiles
fstype: xfs