-
Notifications
You must be signed in to change notification settings - Fork 39
/
disks.yaml
55 lines (47 loc) · 1.19 KB
/
disks.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
48
49
50
51
52
53
54
- name: install mdadm
become: true
become_user: root
apt:
update_cache: yes
pkg:
- mdadm
- name: check raid already exists
become: true
become_user: root
shell: fdisk -l | grep -e 'md0' -e 'md127'
ignore_errors: yes
register: raid_exists
- name: wipe disks
become: true
become_user: root
shell: sfdisk --delete {{ item }}
with_items:
- "{{ raw_disk_list }}"
ignore_errors: yes
when: raid_exists.rc != 0
- name: raid raw disks
become: true
become_user: root
shell: echo y | mdadm --create /dev/md0 --level=0 --raid-devices={{ raw_disk_list|length }} {{ raw_disk_list | join(' ') }}
when: raid_exists.rc != 0
- name: get raid device name
become: true
become_user: root
shell: cat /proc/mdstat | grep md | awk '{print $1}'
register: raid_name
- name: check mount
become: true
become_user: root
shell: df -h | grep mnt
ignore_errors: yes
register: mount_mnt
- name: format disks with ext4
become: true
become_user: root
shell: mkfs.ext4 /dev/{{ raid_name.stdout }}
when: raid_name.rc == 0 and mount_mnt.rc != 0
- name: mount disks
become: true
become_user: root
shell: mount /dev/{{ raid_name.stdout }} /mnt
when: mount_mnt.rc != 0