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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
---
- name: disks
tags:
- disks
block:
- name: check for mounted disk
# Not perfect.
ansible.builtin.command: "grep '{{ item }}' /proc/mounts"
failed_when: false
changed_when: false
register: check_mounted_disk
check_mode: no
loop: "{{ raw_disks }}"
- name: debug
ansible.builtin.debug:
msg: "{{ check_mounted_disk }}"
- name: abort if disk mounted
ansible.builtin.fail:
msg: "Aborting install due to {{ item }} being mounted"
when: item.rc == 0
loop: "{{ check_mounted_disk.results }}"
- name: write partition layout file
ansible.builtin.copy:
dest: /tmp/partition.sfdisk
# This is a consistent disk layout for all systems, EFI or Legacy
# non-LVM RootFS
# TODO: where should boot be set? EFI vs BIOSBP
content: |
label: gpt
p1 : start=1MiB, size=1MiB, type=21686148-6449-6E6F-744E-656564454649, name=BIOS
p2 : start=2MiB, size=62MiB, type=uefi, name=EFI
p3 : start=64MiB, size=448MiB, type=raid, name=BOOT
p4 : start=512MiB, size=30GiB, type=raid, name=ROOT
p5 : start=+, size=+, type=lvm, name=LVM
tags:
- partition
- name: partition disks
ansible.builtin.shell: "sfdisk {{ item }} </tmp/partition.sfdisk"
loop: "{{ raw_disks }}"
tags:
- partition
- name: setup p1 # BIOS_BP
ansible.builtin.meta: noop
- name: mdadm p2
ansible.builtin.command: "mdadm --create -e 1.0 /dev/md2 --level=raid1 -n 2 {{ part2_dev|join(' ') }}"
tags:
- mdadm
- name: mdadm p3
ansible.builtin.command: "mdadm --create -e 1.0 /dev/md3 --level=raid1 -n 2 {{ part3_dev|join(' ') }}"
tags:
- mdadm
- name: mdadm p4
ansible.builtin.command: "mdadm --create -e 1.0 /dev/md4 --level=raid1 -n 2 {{ part4_dev|join(' ') }}"
tags:
- mdadm
- name: format p2/mkfs
ansible.builtin.command: "mkfs.fat -F 16 -n EFI {{ item }}"
tags:
- mkfs
loop:
- /dev/md2
- name: format p3/mkfs
ansible.builtin.command: "mkfs.ext4 -T floppy,news -L BOOT {{ item }}"
loop:
- /dev/md3
tags:
- mkfs
- name: format p4/mkfs
ansible.builtin.command: "mkfs.ext4 -T floppy,news -L ROOT {{ item }}"
loop:
- /dev/md4
tags:
- mkfs
- name: format p5/pvcreate
ansible.builtin.command: "pvcreate {{ part5_dev|join(' ') }}"
tags:
- lvm
- pvcreate
- name: fact vgcreate PVs
ansible.builtin.set_fact:
pvs: "{{ part5_dev|join(' ') }}"
tags:
- lvm
- vgcreate
#when: "{{ pvs }}" = ""
- name: fact vgs
ansible.builtin.set_fact:
vgs: "{{ hostname }}"
tags:
- disk
- mount
- lvm
- name: vgcreate
ansible.builtin.command: "vgcreate {{ hostname }} {{ pvs }}"
tags:
- lvm
- vgcreate
# Dracut has a subtle bug: given rd.lvm=1 rd.lvm.vg=VGNAME as boot paramters,
# and an *empty* VG (no LVs), the boot will hang. Make a LV as workaround.
- name: lvcreate stub
ansible.builtin.command: "lvcreate -L 4m -n test {{ hostname }}"
tags:
- lvm
- lvcreate
|