New warewulf-dracut subpackage

warewulf-dracut includes a dracut module to be installed in a container
image to support building an initramfs that can boot from Warewulf.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-04-16 10:57:58 -06:00
parent a322061fe9
commit 18cebb8652
7 changed files with 94 additions and 2 deletions

View File

@@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add examples for building overlays in parallel to documentation
- Add `stage=initramfs` to warewulfd provision to serve initramfs from container image. #1115
- Add `warewulf-dracut` package to support building Warewulf-compatible initramfs images with dracut. #1115
### Changed

View File

@@ -138,6 +138,8 @@ install: build docs
install -m 0644 etc/bash_completion.d/wwctl $(DESTDIR)$(BASHCOMPDIR)/wwctl
for f in docs/man/man1/*.1.gz; do install -m 0644 $$f $(DESTDIR)$(MANDIR)/man1/; done
for f in docs/man/man5/*.5.gz; do install -m 0644 $$f $(DESTDIR)$(MANDIR)/man5/; done
install -pd -m 0755 $(DESTDIR)$(DRACUTMODDIR)/90wwinit
install -m 0644 dracut/modules.d/90wwinit/*.sh $(DESTDIR)$(DRACUTMODDIR)/90wwinit
.PHONY: installapi
installapi:

View File

@@ -44,10 +44,11 @@ else
endif
# OS-Specific Service Locations
VARLIST += TFTPDIR FIREWALLDDIR SYSTEMDDIR BASHCOMPDIR
VARLIST += TFTPDIR FIREWALLDDIR SYSTEMDDIR BASHCOMPDIR DRACUTMODDIR
SYSTEMDDIR ?= /usr/lib/systemd/system
BASHCOMPDIR ?= /etc/bash_completion.d
FIREWALLDDIR ?= /usr/lib/firewalld/services
DRACUTMODDIR ?= /usr/lib/dracut/modules.d
ifeq ($(OS),suse)
TFTPDIR ?= /srv/tftpboot
endif

View File

@@ -0,0 +1,13 @@
#!/bin/bash
info "Mounting tmpfs at $NEWROOT"
mount -t tmpfs ${wwinit_tmpfs_size_option} tmpfs "$NEWROOT"
for archive in "${wwinit_container}" "${wwinit_kmods}" "${wwinit_system}" "${wwinit_runtime}"
do
if [ -n "${archive}" ]
then
info "Loading ${archive}"
(curl --silent -L "${archive}" | gzip -d | cpio -im --directory="${NEWROOT}") || die "Unable to load ${archive}"
fi
done

View File

@@ -0,0 +1,20 @@
#!/bin/bash
check() {
# Don't include in hostonly mode
[[ $hostonly ]] && return 1
# Don't include by default
return 255
}
depends() {
echo network
return 0
}
install() {
inst_multiple cpio curl
inst_hook cmdline 30 "$moddir/parse-wwinit.sh"
inst_hook pre-mount 30 "$moddir/load-wwinit.sh"
}

View File

@@ -0,0 +1,28 @@
#!/bin/sh
# root=wwinit
[ -z "$root" ] && root=$(getarg root=)
if [ "${root}" = "wwinit" ]
then
info "root=${root}"
export wwinit_container=$(getarg wwinit.container=); info "wwinit.container=${wwinit_container}"
export wwinit_system=$(getarg wwinit.system=); info "wwinit.system=${wwinit_system}"
export wwinit_runtime=$(getarg wwinit.runtime=); info "wwinit.runtime=${wwinit_runtime}"
export wwinit_kmods=$(getarg wwinit.kmods=); info "wwinit.kmods=${wwinit_kmods}"
wwinit_tmpfs_size=$(getarg wwinit.tmpfs.size=)
if [ -n "$wwinit_tmpfs_size" ]
then
info "wwinit.tmpfs.size=${wwinit_tmpfs_size}"
export wwinit_tmpfs_size_option="-o size=${wwinit_tmpfs_size}"
fi
if [ -n "${wwinit_container}" ]
then
info "Found root=${root} and a Warewulf container image. Will boot from Warewulf."
rootok=1
else
die "Found root=${root} but no container image. Cannot boot from Warewulf."
fi
fi

View File

@@ -82,6 +82,23 @@ BuildRequires: libassuan-devel gpgme-devel
Warewulf is a stateless and diskless container operating system provisioning
system for large clusters of bare metal and/or virtual systems.
%package dracut
Summary: dracut module for loading a Warewulf container image
BuildArch: noarch
Requires: dracut
%if 0%{?suse_version}
%else
Requires: dracut-network
%endif
%description dracut
Warewulf is a stateless and diskless container operating system provisioning
system for large clusters of bare metal and/or virtual systems.
This subpackage contains a dracut module that can be used to generate
an initramfs that can fetch and boot a Warewulf container image from a
Warewulf server.
%prep
%setup -q -n %{name}-%{version} -b0 %if %{?with_offline:-a2}
@@ -105,7 +122,8 @@ make defaults \
BASHCOMPDIR=/etc/bash_completion.d/ \
FIREWALLDDIR=/usr/lib/firewalld/services \
WWCLIENTDIR=/warewulf \
IPXESOURCE=/usr/share/ipxe
IPXESOURCE=/usr/share/ipxe \
DRACUTMODDIR=/usr/lib/dracut/modules.d
make
%if %{api}
make api
@@ -185,7 +203,16 @@ getent group %{wwgroup} >/dev/null || groupadd -r %{wwgroup}
%endif
%files dracut
%defattr(-, root, root)
%dir %{_prefix}/lib/dracut/modules.d/90wwinit
%{_prefix}/lib/dracut/modules.d/90wwinit/*.sh
%changelog
* Thu Apr 18 2024 Jonathon Anderson <janderson@ciq.com>
- New warewulf-dracut subpackage
* Wed Apr 17 2024 Jonathon Anderson <janderson@ciq.com>
- Don't build the API on EL7