-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicro_storage.yml
232 lines (207 loc) · 5.64 KB
/
micro_storage.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# ansible-galaxy collection install linux_system_roles.storage
# then
# cd ~/.ansible/collections/ansible_collections/fedora/linux_system_roles/requirements.yml
# ansible-galaxy collection install -vv -r requirements.yml
- hosts: micro.lan
#connection: local
become: yes
roles:
- fedora.linux_system_roles.storage
- geerlingguy.nfs
tasks:
- name: Create the physical volume (PV)
lvg:
vg: fedora_micro
pvs: /dev/sda3
tags:
- lvm
- name: Create the logical volume on disk for root
lvol:
vg: fedora_micro
lv: root
size: 20g
tags:
- lvm
- name: Create the filesystem for root
filesystem:
fstype: xfs
dev: /dev/fedora_micro/root
resizefs: yes
tags:
- lvm
- name: Mount the filesystem
mount:
path: /
src: /dev/mapper/fedora_micro-root
fstype: xfs
state: mounted
backup: yes
tags:
- lvm
- name: Create the logical volume on disk for vm_pool
lvol:
vg: fedora_micro
lv: vm_pool
size: 100g
tags:
- lvm
- name: Create the filesystem for vm_pool
filesystem:
fstype: xfs
dev: /dev/fedora_micro/vm_pool
resizefs: yes
tags:
- lvm
- name: Mount the filesystem for vm_pool
mount:
path: /var/lib/libvirt/vm-pool
src: /dev/mapper/fedora_micro-vm_pool
fstype: xfs
state: mounted
backup: yes
tags:
- lvm
- name: Create the logical volume on disk for user_containers
lvol:
vg: fedora_micro
lv: user_containers
size: 20g
tags:
- lvm
- name: Create the filesystem for user_containers
filesystem:
fstype: xfs
dev: /dev/fedora_micro/user_containers
resizefs: yes
tags:
- lvm
- name: Mount the filesystem for user_containers
mount:
path: /mnt/containers
src: /dev/mapper/fedora_micro-user_containers
fstype: xfs
state: mounted
backup: yes
tags:
- lvm
- name: Create the logical volume on disk for root_containers
lvol:
vg: fedora_micro
lv: root_containers
size: 20g
tags:
- lvm
- name: Create the filesystem for root_containers
filesystem:
fstype: xfs
dev: /dev/fedora_micro/root_containers
resizefs: yes
tags:
- lvm
- name: Mount the filesystem for root_containers
mount:
path: /var/lib/containers
src: /dev/mapper/fedora_micro-root_containers
fstype: xfs
state: mounted
backup: yes
tags:
- lvm
- name: Create the logical volume on disk for vm_images
lvol:
vg: fedora_micro
lv: vm_images
size: 100g
tags:
- lvm
- name: Create the filesystem for vm_images
filesystem:
fstype: xfs
dev: /dev/fedora_micro/vm_images
resizefs: yes
tags:
- lvm
- name: Mount the filesystem for vm_images
mount:
path: /mnt/vm_images
src: /dev/mapper/fedora_micro-vm_images
fstype: xfs
state: mounted
backup: yes
tags:
- lvm
- name: Create mount points for media/backups
file:
path: "{{ item }}"
state: directory
mode: '0755'
owner: root
group: root
loop:
- /mnt/sg1
- /mnt/sg2
- /mnt/sg3
tags:
- nfs
- name: Mount the filesystem for media/backups
mount:
path: /mnt/sg1
src: LABEL=SEAGATE1
fstype: ext4
state: mounted
backup: yes
- name: Mount media/backups filesystem from NUC
mount:
src: nuc.lan:/mnt/sg2
path: /mnt/sg2
opts: x-systemd.after=network-online.target
state: mounted
fstype: nfs
tags:
- nfs
- name: Open the appropriate firewall ports for NFS
firewalld:
zone: FedoraServer
service: '{{ item }}'
permanent: yes
immediate: yes
state: enabled
loop:
- nfs
- nfs3
- mountd
- rpc-bind
tags:
- nfs
# Fix the SELinux permissions for user container storage as per:
# https://github.com/containers/podman/issues/12812
# https://github.com/containers/podman/issues/3234
# $ sudo semanage fcontext -a -e $HOME/.local/share/containers /mnt/containers
# $ restorecon -R -v /mnt
- name: Allow users to modify files in their local container storage directories
community.general.sefcontext:
#target: '/mnt/containers(/.*)?'
target: '/mnt/containers'
# Trying to set seuser is redundant when using SELinux targeted policy
seuser: unconfined_u
setype: data_home_t
state: present
tags:
- selinux
- name: Apply new SELinux file context to filesystem
#ansible.builtin.command: restorecon -irv /mnt/containers
ansible.builtin.command: restorecon -iv /mnt/containers
tags:
- selinux
# Edit /etc/containers.conf to ensure rootless containers are stored in correct location
# OLD: # rootless_storage_path = "$HOME/.local/share/containers/storage"
# NEW: rootless_storage_path = "/mnt/containers/$USER/storage"
- name: Ensure that rootless container storage is in the correct directory
lineinfile:
path: /etc/containers/storage.conf
regexp: '^rootless_storage_path'
insertafter: '^# rootless_storage_path'
line: rootless_storage_path = "/mnt/containers/$USER/storage"
backup: yes
tags:
- podman