Use systemd mount units for mounting ignition

Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
Christian Goll
2023-08-15 17:36:40 -06:00
committed by Jonathon Anderson
parent cfbb38d570
commit d96c55022d
7 changed files with 68 additions and 17 deletions

View File

@@ -7,8 +7,17 @@ devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /run/shm tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
{{- if .FileSystems }}
# mounts for local file systems created with ignition in nodes.conf
# all with noauto as mounts happens with systemd units
{{- range $fsdevice,$fs := .FileSystems }}
{{ $fsdevice }} {{ $fs.Path }} {{ $fs.Format }}
{{- if $fs.MountOptions }} noauto{{range $index,$opt := $fs.MountOptions }},{{ $opt }}{{ end }} 0 0
{{- else }} noauto,defaults 0 0
{{- end }}{{ end }}{{ end }}
{{- $IP:=.Ipaddr }}
{{- if .Nfs.Enabled }}
# nfs mounts provided in warewulf.conf
{{- range .Nfs.ExportsExtended }}
{{- if .Mount }}
{{ $IP }}:{{ .Path }} {{ .Path }} nfs {{ .MountOptions }} 0 0

View File

@@ -1,16 +0,0 @@
[Unit]
Description=Ignition warewulf (mount)
Documentation=https://hpcng.github.io/warewulf
ConditionPathExists=/warewulf/ignition.json
ConditionPathExists=/usr/lib/dracut/modules.d/30ignition/ignition
DefaultDependencies=false
Before=ignition-complete.target
After=ignition-ww4-disks.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/dracut/modules.d/30ignition/ignition --platform=metal --stage=mount --config-cache /warewulf/ignition.json
ExecStop=/usr/lib/dracut/modules.d/30ignition/ignition --platform=metal --stage=umount --config-cache /warewulf/ignition.json

View File

@@ -0,0 +1 @@
/etc/systemd/system/ww4-disks.target

View File

@@ -1 +0,0 @@
/etc/systemd/system/ignition-ww4-mount.service

View File

@@ -0,0 +1,20 @@
# This file is autogenerated by warewulf
# Host: {{.BuildHost}}
# Time: {{.BuildTime}}
# Source: {{.BuildSource}}
[Unit]
Description=mount ww4 disks
# make sure that the disks are available
Requires=ignition-ww4-disks.service
After=ignition-ww4-disks.service
Prequisite=ignition-ww4-disks.service
# Get the mounts
{{- range $fsdevice,$fs := .FileSystems }}
{{- $prefix := $fsdevice }}{{ $suffix := "mount" }}
{{- if eq $fs.Format "swap"}}
{{- $prefix = tr $fsdevice "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-"}}{{ $suffix = "swap"}}
{{- else }}
{{- if $fs.Path }}{{ $prefix = tr $fs.Path "/" "" }}{{ end }}
{{- end }}
Wants={{ print $prefix "." $suffix }}
{{- end }}

View File

@@ -0,0 +1,38 @@
{{- $host := .BuildHost }}
{{- $time := .BuildTime }}
{{- $source := .BuildSource }}
{{- range $fsdevice,$fs := .FileSystems }}
{{- $prefix := tr $fs.Path "/" "" }}{{ $suffix:="mount"}}
{{- if $fs.Label }}{{ $prefix = $fs.Label }}{{ end }}
{{- if eq $fs.Format "swap"}}{{ $prefix = tr $fsdevice "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-"}}{{ $suffix = "swap"}}{{ end }}
{{- $filename := print $prefix "." $suffix }}
{{- file $filename }}
# This file is autogenerated by warewulf
# Host: {{ $host }}
# Time: {{ $time }}
# Source: {{ $source }}
{{- if eq $fs.Format "swap"}}
[Unit]
ConditionPathExists=/warewulf/ignition.json
After=ignition-ww4-disks.service
Before=swap.target
[Swap]
What={{ $fsdevice }}
[Install]
RequiredBy=swap.target
{{- else }}
[Unit]
ConditionPathExists=/warewulf/ignition.json
Before=local-fs.target
After=ignition-ww4-disks.service
[Mount]
Where={{ $fs.Path }}
What={{ $fsdevice }}
Type={{ $fs.Format }}
{{- if $fs.MountOptions }}
Options={{range $index,$opt := $fs.MountOptions }}{{if $index }},{{ end }}{{ $opt }}{{ end }}
{{- end }}
[Install]
RequiredBy=local-fs.target
{{- end }}
{{- end }}