-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathdisk_resize.yml
47 lines (39 loc) · 1.27 KB
/
disk_resize.yml
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
---
- hosts: all
gather_facts: true
connection: smart
tasks:
- name: "DISK | Create a partition for the added disk space"
expect:
command: /sbin/fdisk /dev/sda
responses:
'Command \(m for help\):':
- 'n'
- 't'
- 'w'
'Select \(default.*$': 'p'
'Partition number.*$': "{{ next_part }}"
'First sector.*$': "\n"
'Last sector.*$': "\n"
'Hex code.*$': '08e'
echo: yes
ignore_errors: yes
register: fdisker
- name: "PRINT | fdisker output"
debug:
msg: "{{ fdisker.stdout }}"
- name: "DISK | Scan for new disk space"
command: partprobe -s
- name: "DISK | Create a physical volume on the new space with LVM"
command: pvcreate /dev/sda{{ next_part }}
ignore_errors: yes
- name: "DISK | Extend the volume group with LVM"
command: vgextend rhel /dev/sda{{ next_part }}
ignore_errors: yes
- name: "DISK | Extend the logical volume with LVM"
command: lvextend -L{{ item.size }} {{ item.part }}
with_items: "{{ mount }}"
ignore_errors: yes
- name: "DISK | Grow the file system into the new space"
command: xfs_growfs -d {{ item.part }}
with_items: "{{ mount }}"