forked from Sheridan/home-it
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgentoo-install.yaml
151 lines (135 loc) · 3.53 KB
/
gentoo-install.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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
- hosts: gentoo_install
vars:
flags:
delete_partitions: no
disks:
- /dev/sda
- /dev/sdb
partitions:
- name: bios_boot
number: 1
flags: ['bios_grub']
size:
start: 0%
end: 16MiB
- name: swap
number: 2
flags: []
size:
start: 16MiB
end: 4GiB
- name: root
number: 3
flags: ['boot']
size:
start: 4GiB
end: 100%
tasks:
- name: Чтение инфо про диски
parted:
device: "{{ item }}"
unit: MiB
register: disk_info
loop: "{{ disks }}"
# - name: Диски
# debug:
# msg: "{{ disk_info }}"
# - name: Диски будут
# debug:
# msg: "{{ item }}"
# loop: "{{ disks | product(partitions) | list }}"
- name: Удаление разделов с диска
parted:
device: "{{ item.0.disk.dev }}"
number: "{{ item.1.num }}"
state: absent
loop: '{{ disk_info.results|subelements("partitions") }}'
register: r_partitions_removed
when: flags.delete_partitions
- name: Создание метки
parted:
label: gpt
device: "{{ item }}"
loop: "{{ disks }}"
when: r_partitions_removed.changed|default(False)
- name: Создание разделов
parted:
device: "{{ item.0 }}"
number: "{{ item.1.number }}"
name: "{{ item.1.name }}"
flags: "{{ item.1.flags }}"
part_start: "{{ item.1.size.start }}"
part_end: "{{ item.1.size.end }}"
part_type: primary
state: present
unit: 'compact'
label: gpt
loop: "{{ disks | product(partitions) | list }}"
when: r_partitions_removed.changed|default(False)
# - name: Создание ФС
# filesystem:
# fstype: "{{ item.1.filesystem }}"
# dev: "{{ item.0 }}{{ item.1.number }}"
# loop: "{{ disks | product(partitions) | list }}"
- name: Создание swap
filesystem:
dev: "{{ item }}2"
fstype: swap
loop: "{{ disks }}"
- name: Создание btrfs
shell: >
mkfs.btrfs
--label root
--data raid1
--metadata raid1
--force
{{ disks | map('regex_replace', '(.*)', '\1_3') | list | map('regex_replace', '_', '') | list | join(' ') }}
- name: check directoryes
file:
dest: "{{ item }}"
state: directory
with_items:
- /mnt/gentoo
- name: Mount up root
mount:
path: /mnt/gentoo
src: LABEL=root
fstype: btrfs
state: present
- name: Creating volumes
shell: "btrfs subvol create {{ item }}"
args:
chdir: /mnt/gentoo
loop:
- root
- portage
- boot
- name: Unmount
mount:
path: /mnt/gentoo
state: unmounted
- name: Mount up root
mount:
path: /mnt/gentoo
src: LABEL=root
fstype: btrfs
state: present
opts: defaults,noatime,subvol=root
- name: check directoryes
file:
dest: "{{ item }}"
state: directory
with_items:
- /mnt/gentoo/boot
- /mnt/gentoo/usr
- /mnt/gentoo/usr/portage
- name: Mount up all
mount:
path: /mnt/gentoo
src: LABEL=root
fstype: btrfs
state: present
opts: defaults,noatime,subvol=root
loop:
-