8000 New Deployment Steps: ZFS, Directory & ZT Checks · unkn0wnAPI/sysadmin-scripts@ea0a0cb · GitHub
[go: up one dir, main page]

Skip to content

Commit ea0a0cb

Browse files
committed
New Deployment Steps: ZFS, Directory & ZT Checks
1 parent c83e390 commit ea0a0cb

File tree

1 file changed

+58
-6
lines changed

1 file changed

+58
-6
lines changed

Universal/PyInfra/ArchServer/deploy.py

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from pyinfra import host
1212
from pyinfra.api import deploy
1313
from pyinfra.facts.server import User
14-
from pyinfra.operations import pacman, server, git, systemd
14+
from pyinfra.facts.files import Directory
15+
from pyinfra.operations import pacman, server, git, systemd, files
1516

1617
#
1718
## Configuration is done using inventory.py
@@ -104,6 +105,14 @@ def install_packages():
104105

105106
@deploy("AUR Integration")
106107
def preparing_aur_support():
108+
files.directory(
109+
name=f"Creating .local directory",
110+
path=f'/home/{host.get_fact(User)}/.local',
111+
present=True,
112+
group=host.data.get("ssh_user"),
113+
user=host.data.get("ssh_user")
114+
)
115+
107116
server.shell(
108117
name = "Fixing ownership of the `.local` user folder",
109118
commands = [f"chown {host.get_fact(User)}:{host.get_fact(User)} /home/{host.get_fact(User)}/.local -R"],
@@ -152,6 +161,11 @@ def install_aur_packages():
152161
commands = ["paru -S --noconfirm --cleanafter autojump"],
153162
)
154163

164+
server.shell(
165+
name = "ZFS Modules",
166+
commands = ["paru -S --noconfirm --cleanafter zfs-dkms zfs-utils"]
167+
)
168+
155169
@deploy("User Environment Configuration")
156170
def user_configuration():
157171
server.shell(
@@ -168,11 +182,12 @@ def user_configuration():
168182

169183
@deploy("Service Preparation")
170184
def service_configuration():
171-
server.shell(
172-
name = "Joining Zerotier network",
173-
commands = [f"zerotier-cli join {host.data.get("ZEROTIER_NETWORK_ID")}"],
174-
_sudo = True
175-
)
185+
if host.data.get("ZEROTIER_NETWORK_ID") != "":
186+
server.shell(
187+
name = "Joining Zerotier network",
188+
commands = [f"zerotier-cli join {host.data.get("ZEROTIER_NETWORK_ID")}"],
189+
_sudo = True
190+
)
176191

177192
server.shell(
178193
name = "Enabling telegraf docker integration",
@@ -277,6 +292,43 @@ def system_services():
277292
_sudo = True
278293
)
279294

295+
server.shell(
296+
name="Add zfs to mkinitcpio.conf MODULES=() line if not present",
297+
commands=[r"sed -i '/^MODULES=/ {/zfs/! s/)/ zfs)/}' /etc/mkinitcpio.conf"],
298+
_sudo = True
299+
)
300+
301+
server.shell(
302+
name="Regenerate initramfs with mkinitcpio for ZFS Modules",
303+
commands=["mkinitcpio -P"],
304+
_sudo = True
305+
)
306+
307+
systemd.service(
308+
name = "Enabling ZFS",
309+
service = "zfs.target",
310+
running = True,
311+
enabled = True,
312+
_sudo = True
313+
)
314+
315+
systemd.service(
316+
name = "Enabling ZFS Import Scan",
317+
service = "zfs-import-scan.service",
318+
running = True,
319+
enabled = True,
320+
_sudo = True
321+
)
322+
323+
systemd.service(
324+
name = "Enabling ZFS Volume Wait",
325+
service = "zfs-volume-wait.service",
326+
running = True,
327+
enabled = True,
328+
_sudo = True
329+
)
330+
331+
280332
@deploy("Post-deployment Tasks")
281333
def post_deployment():
282334
server.shell(

0 commit comments

Comments
 (0)
0