SHA256
1
0
forked from pool/warewulf4

Accepting request 1060671 from home:mslacken:pr

- added make-ipxe-binary-source-configureable.patch

OBS-URL: https://build.opensuse.org/request/show/1060671
OBS-URL: https://build.opensuse.org/package/show/network:cluster/warewulf4?expand=0&rev=23
This commit is contained in:
Christian Goll 2023-01-24 16:07:05 +00:00 committed by Git OBS Bridge
parent b90fe3bfc3
commit 01b11d7da4
3 changed files with 211 additions and 33 deletions

View File

@ -0,0 +1,163 @@
From 32ab50f299502fce7bf588852a75c63cf3332cf8 Mon Sep 17 00:00:00 2001
From: Christian Goll <cgoll@suse.de>
Date: Fri, 20 Jan 2023 15:05:42 +0100
Subject: [PATCH] make ipxe binary source configureable
---
internal/pkg/buildconfig/defaults.go | 2 +-
internal/pkg/configure/tftp.go | 17 ++++++++++-------
internal/pkg/overlay/datastructure.go | 2 ++
internal/pkg/warewulfconf/constructors.go | 12 ++++++++++--
internal/pkg/warewulfconf/datastructure.go | 2 ++
overlays/host/etc/dhcp/dhcpd.conf.ww | 14 +++++---------
6 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/internal/pkg/buildconfig/defaults.go b/internal/pkg/buildconfig/defaults.go
index 24cb2d40..17baecba 100644
--- a/internal/pkg/buildconfig/defaults.go
+++ b/internal/pkg/buildconfig/defaults.go
@@ -27,7 +27,7 @@ func BINDIR() string {
}
func DATADIR() string {
- wwlog.Debug("DATADIR = '%s'", bindir)
+ wwlog.Debug("DATADIR = '%s'", datadir)
return datadir
}
diff --git a/internal/pkg/configure/tftp.go b/internal/pkg/configure/tftp.go
index d321f023..842d7fb4 100644
--- a/internal/pkg/configure/tftp.go
+++ b/internal/pkg/configure/tftp.go
@@ -11,9 +11,8 @@ import (
"github.com/hpcng/warewulf/internal/pkg/wwlog"
)
-var tftpdir string = path.Join(buildconfig.TFTPDIR(), "warewulf")
-
func TFTP() error {
+ var tftpdir string = path.Join(buildconfig.TFTPDIR(), "warewulf")
controller, err := warewulfconf.New()
if err != nil {
wwlog.Error("%s", err)
@@ -27,11 +26,15 @@ func TFTP() error {
}
fmt.Printf("Writing PXE files to: %s\n", tftpdir)
- for _, f := range [4]string{"x86_64.efi", "x86_64.kpxe", "arm64.efi"} {
- err = util.SafeCopyFile(path.Join(buildconfig.DATADIR(), "warewulf", "ipxe", f), path.Join(tftpdir, f))
+ copyCheck := make(map[string]bool)
+ for _, f := range controller.Tftp.IpxeBinaries {
+ if copyCheck[f] {
+ continue
+ }
+ copyCheck[f] = true
+ err = util.SafeCopyFile(path.Join(buildconfig.DATADIR(), f), path.Join(tftpdir, f))
if err != nil {
- wwlog.Error("%s", err)
- return err
+ wwlog.Warn("ipxe binary could not be copied, not booting may not work: %s", err)
}
}
@@ -39,7 +42,7 @@ func TFTP() error {
wwlog.Info("Warewulf does not auto start TFTP services due to disable by warewulf.conf")
os.Exit(0)
}
-
+
fmt.Printf("Enabling and restarting the TFTP services\n")
err = util.SystemdStart(controller.Tftp.SystemdName)
if err != nil {
diff --git a/internal/pkg/overlay/datastructure.go b/internal/pkg/overlay/datastructure.go
index 2a427bee..eb8004cf 100644
--- a/internal/pkg/overlay/datastructure.go
+++ b/internal/pkg/overlay/datastructure.go
@@ -31,6 +31,7 @@ type TemplateStruct struct {
Dhcp warewulfconf.DhcpConf
Nfs warewulfconf.NfsConf
Warewulf warewulfconf.WarewulfConf
+ Tftp warewulfconf.TftpConf
AllNodes []node.NodeInfo
node.NodeConf
// backward compatiblity
@@ -64,6 +65,7 @@ func InitStruct(nodeInfo node.NodeInfo) TemplateStruct {
tstruct.AllNodes = allNodes
tstruct.Nfs = *controller.Nfs
tstruct.Dhcp = *controller.Dhcp
+ tstruct.Tftp = *controller.Tftp
tstruct.Warewulf = *controller.Warewulf
tstruct.Ipaddr = controller.Ipaddr
tstruct.Ipaddr6 = controller.Ipaddr6
diff --git a/internal/pkg/warewulfconf/constructors.go b/internal/pkg/warewulfconf/constructors.go
index 1d68564a..904d0d31 100644
--- a/internal/pkg/warewulfconf/constructors.go
+++ b/internal/pkg/warewulfconf/constructors.go
@@ -36,8 +36,14 @@ func New() (ControllerConf, error) {
ret.Tftp = &tftpconf
ret.Nfs = &nfsConf
err := defaults.Set(&ret)
+ // ipxe binaries are merged not overwritten, store defaults separate
+ defIpxe := make(map[string]string)
+ for k, v := range ret.Tftp.IpxeBinaries {
+ defIpxe[k] = v
+ delete(ret.Tftp.IpxeBinaries, k)
+ }
if err != nil {
- wwlog.Error("Coult initialize default variables")
+ wwlog.Error("Could initialize default variables")
return ret, err
}
// Check if cached config is old before re-reading config file
@@ -53,7 +59,9 @@ func New() (ControllerConf, error) {
if err != nil {
return ret, err
}
-
+ if len(ret.Tftp.IpxeBinaries) == 0 {
+ ret.Tftp.IpxeBinaries = defIpxe
+ }
if ret.Ipaddr == "" || ret.Netmask == "" {
conn, error := net.Dial("udp", "8.8.8.8:80")
if error != nil {
diff --git a/internal/pkg/warewulfconf/datastructure.go b/internal/pkg/warewulfconf/datastructure.go
index c3eebf8c..eb195a2e 100644
--- a/internal/pkg/warewulfconf/datastructure.go
+++ b/internal/pkg/warewulfconf/datastructure.go
@@ -44,6 +44,8 @@ type TftpConf struct {
Enabled bool `yaml:"enabled" default:"true"`
TftpRoot string `yaml:"tftproot" default:"/var/lib/tftpboot"`
SystemdName string `yaml:"systemd name" default:"tftp"`
+ // Path is relative to buildconfig.DATADIR()
+ IpxeBinaries map[string]string `yaml:"ipxe" default:"{\"00:09\": \"x86_64.efi\",\"00:00\": \"x86_64.kpxe\",\"00:0B\": \"arm64.efi\",\"00:07\": \"x86_64.efi\"}"`
}
type NfsConf struct {
diff --git a/overlays/host/etc/dhcp/dhcpd.conf.ww b/overlays/host/etc/dhcp/dhcpd.conf.ww
index 82b96cec..66b9d22e 100644
--- a/overlays/host/etc/dhcp/dhcpd.conf.ww
+++ b/overlays/host/etc/dhcp/dhcpd.conf.ww
@@ -20,15 +20,11 @@ option architecture-type code 93 = unsigned integer 16;
if exists user-class and option user-class = "iPXE" {
filename "http://{{$.Ipaddr}}:{{$.Warewulf.Port}}/ipxe/${mac:hexhyp}";
} else {
- if option architecture-type = 00:0B {
- filename "/warewulf/arm64.efi";
- } elsif option architecture-type = 00:09 {
- filename "/warewulf/x86_64.efi";
- } elsif option architecture-type = 00:07 {
- filename "/warewulf/x86_64.efi";
- } elsif option architecture-type = 00:00 {
- filename "/warewulf/x86_64.kpxe";
- }
+{{range $type,$name := $.Tftp.IpxeBinaries }}
+ if option architecture-type = {{ $type }} {
+ filename "/warewulf/{{ $name }}";
+ }
+{{ end }}
}
{{if eq .Dhcp.Template "static" -}}
--
2.39.0

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Jan 24 11:17:32 UTC 2023 - Christian Goll <cgoll@suse.com>
- added make-ipxe-binary-source-configureable.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Jan 19 11:13:58 UTC 2023 - Christian Goll <cgoll@suse.com> Thu Jan 19 11:13:58 UTC 2023 - Christian Goll <cgoll@suse.com>

View File

@ -30,7 +30,7 @@ URL: https://warewulf.org
Source0: https://github.com/hpcng/warewulf/archive/v%{version}%{?rls_cndt}.tar.gz#/warewulf4-v%{version}.tar.gz Source0: https://github.com/hpcng/warewulf/archive/v%{version}%{?rls_cndt}.tar.gz#/warewulf4-v%{version}.tar.gz
Source1: vendor.tar.gz Source1: vendor.tar.gz
Source3: warewulf4-rpmlintrc Source3: warewulf4-rpmlintrc
#Patch1: upstream.patch Patch1: make-ipxe-binary-source-configureable.patch
# no firewalld in sle12 # no firewalld in sle12
%if 0%{?sle_version} >= 150000 || 0%{?suse_version} > 1500 %if 0%{?sle_version} >= 150000 || 0%{?suse_version} > 1500
@ -44,12 +44,16 @@ BuildRequires: make
BuildRequires: munge BuildRequires: munge
BuildRequires: sysuser-tools BuildRequires: sysuser-tools
BuildRequires: tftp BuildRequires: tftp
BuildRequires: yq
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
Requires: %{name}-ipxe = %{version} #Requires: %{name}-ipxe = %{version}
Requires: %{name}-overlay = %{version} Requires: %{name}-overlay = %{version}
Requires: dhcp-server Recommends: dhcp-server
Requires: ipmitool Recommends: ipmitool
Requires: nfs-kernel-server Recommends: ipxe-bootimgs
Recommends: ipxe-bootimgs
Recommends: nfs-kernel-server
Recommends: tftp
%{go_nostrip} %{go_nostrip}
@ -77,13 +81,13 @@ Summary: Contains the service for the warewulf rest API
Containts the binaries for the access of warewulf through a rest API and from the commandline from an external host. Containts the binaries for the access of warewulf through a rest API and from the commandline from an external host.
%package ipxe %package ipxe
Requires: tftp
Summary: Binaries of iPXE for ww4 installation Summary: Binaries of iPXE for ww4 installation
BuildArch: noarch BuildArch: noarch
%description ipxe %description ipxe
For the boot of the nodes iPXE binaries are needed. As these package includes these files for For the boot of the nodes iPXE binaries are needed. As these package includes these files for
x86, i386 and ARM. x86, i386 and ARM.
These are the binaries from the upstream project.
%package slurm %package slurm
Summary: Configuration template for slurm Summary: Configuration template for slurm
@ -106,7 +110,7 @@ make %{?_smp_mflags} genconfig \
PREFIX=%{_prefix} \ PREFIX=%{_prefix} \
BINDIR=%{_bindir} \ BINDIR=%{_bindir} \
SYSCONFDIR=%{_sysconfdir} \ SYSCONFDIR=%{_sysconfdir} \
DATADIR=%{_datadir} \ DATADIR=%{_datadir}/ipxe \
LOCALSTATEDIR=%{_datadir} \ LOCALSTATEDIR=%{_datadir} \
SHAREDSTATEDIR=%{_sharedstatedir} \ SHAREDSTATEDIR=%{_sharedstatedir} \
MANDIR=%{_mandir} \ MANDIR=%{_mandir} \
@ -136,6 +140,15 @@ mv -v %{buildroot}%{_sysconfdir}/bash_completion.d/warewulf %{buildroot}%{_datad
#cp %{S:2} %{buildroot}%{_sysconfdir}/warewulf/warewulf.conf #cp %{S:2} %{buildroot}%{_sysconfdir}/warewulf/warewulf.conf
#rm -rf %{buildroot}%{_datadir}/warewulf/ipxe #rm -rf %{buildroot}%{_datadir}/warewulf/ipxe
rm -f %{buildroot}/usr/share/doc/packages/warewulf/LICENSE.md rm -f %{buildroot}/usr/share/doc/packages/warewulf/LICENSE.md
rm -rf %{buildroot}%{_localstatedir}/lib/warewulf
# use ipxe-bootimgs images
yq e '
.tftp.ipxe."00:00" = "undionly.kpxe" |
.tftp.ipxe."00:07" = "ipxe-x86_64.efi" |
.tftp.ipxe."00:09" = "ipxe-x86_64.efi" |
.tftp.ipxe."00:0B" = "snp-arm64.efi"'\
-i %{buildroot}%{_sysconfdir}/warewulf/warewulf.conf
sed -i 's@\(^\s*\)\(.*:.*\):@\1"\2":@' %{buildroot}%{_sysconfdir}/warewulf/warewulf.conf
# create systemuser # create systemuser
echo "u warewulf -" > system-user-%{name}.conf echo "u warewulf -" > system-user-%{name}.conf
@ -144,15 +157,15 @@ echo "g warewulf -" >> system-user-%{name}.conf
install -D -m 644 system-user-%{name}.conf %{buildroot}%{_sysusersdir}/system-user-%{name}.conf install -D -m 644 system-user-%{name}.conf %{buildroot}%{_sysusersdir}/system-user-%{name}.conf
# get the slurm package readay # get the slurm package readay
mkdir -p %{buildroot}%{_localstatedir}/lib/warewulf/overlays/host/etc/slurm mkdir -p %{buildroot}%{_datadir}/warewulf/overlays/host/etc/slurm
mv %{buildroot}%{_sysconfdir}/warewulf/examples/slurm.conf.ww %{buildroot}%{_localstatedir}/lib/warewulf/overlays/host/etc/slurm mv %{buildroot}%{_sysconfdir}/warewulf/examples/slurm.conf.ww %{buildroot}%{_datadir}/warewulf/overlays/host/etc/slurm
mkdir -p %{buildroot}%{_localstatedir}/lib/warewulf/overlays/generic/etc/munge mkdir -p %{buildroot}%{_datadir}/warewulf/overlays/generic/etc/munge
cat > %{buildroot}%{_localstatedir}/lib/warewulf/overlays/generic/etc/munge/munge.key.ww <<EOF cat > %{buildroot}%{_datadir}/warewulf/overlays/generic/etc/munge/munge.key.ww <<EOF
{{ Include "/etc/munge/munge.key" -}} {{ Include "/etc/munge/munge.key" -}}
EOF EOF
chmod 600 %{buildroot}%{_localstatedir}/lib/warewulf/overlays/generic/etc/munge/munge.key.ww chmod 600 %{buildroot}%{_datadir}/warewulf/overlays/generic/etc/munge/munge.key.ww
mkdir -p %{buildroot}%{_localstatedir}/lib/warewulf/overlays/generic/etc/slurm mkdir -p %{buildroot}%{_datadir}/warewulf/overlays/generic/etc/slurm
cat > %{buildroot}%{_localstatedir}/lib/warewulf/overlays/generic/etc/slurm/slurm.conf.ww <<EOF cat > %{buildroot}%{_datadir}/warewulf/overlays/generic/etc/slurm/slurm.conf.ww <<EOF
{{ Include "/etc/slurm/slurm.conf" }} {{ Include "/etc/slurm/slurm.conf" }}
EOF EOF
@ -174,19 +187,16 @@ EOF
%license LICENSE.md %license LICENSE.md
%attr(0755, root, warewulf) %dir %{_sysconfdir}/warewulf %attr(0755, root, warewulf) %dir %{_sysconfdir}/warewulf
%attr(0755, root, warewulf) %dir %{_sysconfdir}/warewulf/examples %attr(0755, root, warewulf) %dir %{_sysconfdir}/warewulf/examples
%attr(0755, root, warewulf) %dir %{_sysconfdir}/warewulf/ipxe
%{_datadir}/bash-completion/completions/wwctl %{_datadir}/bash-completion/completions/wwctl
%{_mandir}/man1/wwctl*1.gz %{_mandir}/man1/wwctl*1.gz
%{_mandir}/man5/*conf*gz %{_mandir}/man5/*conf*gz
%config(noreplace) %{_sysconfdir}/warewulf/nodes.conf %config(noreplace) %{_sysconfdir}/warewulf/nodes.conf
%config(noreplace) %{_sysconfdir}/warewulf/warewulf.conf %config(noreplace) %{_sysconfdir}/warewulf/warewulf.conf
%config(noreplace) %{_sysconfdir}/warewulf/defaults.conf %config(noreplace) %{_sysconfdir}/warewulf/defaults.conf
%config(noreplace) %{_sysconfdir}/warewulf/ipxe
%config(noreplace) %{_sysconfdir}/warewulf/ipxe/*.ipxe
%{_sysconfdir}/warewulf/examples %{_sysconfdir}/warewulf/examples
%{_prefix}/lib/firewalld/services/warewulf.xml %{_prefix}/lib/firewalld/services/warewulf.xml
%{_localstatedir}/lib/warewulf %exclude %{_datadir}/warewulf/overlays
%exclude %{_localstatedir}/lib/warewulf/overlays
%{_bindir}/wwctl %{_bindir}/wwctl
%{_sbindir}/rcwarewulfd %{_sbindir}/rcwarewulfd
%{_unitdir}/warewulfd.service %{_unitdir}/warewulfd.service
@ -196,14 +206,14 @@ EOF
# The configuration files in this location are for the compute # The configuration files in this location are for the compute
# nodes, so when modified we do not replace them as sensible # nodes, so when modified we do not replace them as sensible
# admin will read the changelog # admin will read the changelog
%config(noreplace) %{_localstatedir}/lib/warewulf/overlays %dir %{_datadir}/warewulf/
%exclude %{_localstatedir}/lib/warewulf/overlays/host/etc/slurm %config(noreplace) %{_datadir}/warewulf/overlays
%exclude %{_localstatedir}/lib/warewulf/overlays/generic/etc/slurm %exclude %{_datadir}/warewulf/overlays/host/etc/slurm
%exclude %{_localstatedir}/lib/warewulf/overlays/generic/etc/munge %exclude %{_datadir}/warewulf/overlays/generic/etc/slurm
%exclude %{_datadir}/warewulf/overlays/generic/etc/munge
%files ipxe %files ipxe
#/srv/tftpboot/warewulf %{_datadir}/ipxe
%{_datadir}/warewulf
%files api %files api
%{_bindir}/wwapic %{_bindir}/wwapic
@ -214,13 +224,13 @@ EOF
%config(noreplace) %{_sysconfdir}/warewulf/wwapird.conf %config(noreplace) %{_sysconfdir}/warewulf/wwapird.conf
%files slurm %files slurm
%dir %{_localstatedir}/lib/warewulf/overlays/host/etc/slurm %dir %{_datadir}/warewulf/overlays/host/etc/slurm
%{_localstatedir}/lib/warewulf/overlays/host/etc/slurm/slurm.conf.ww %{_datadir}/warewulf/overlays/host/etc/slurm/slurm.conf.ww
%dir %{_localstatedir}/lib/warewulf/overlays/generic/etc/slurm %dir %{_datadir}/warewulf/overlays/generic/etc/slurm
%{_localstatedir}/lib/warewulf/overlays/generic/etc/slurm/slurm.conf.ww %{_datadir}/warewulf/overlays/generic/etc/slurm/slurm.conf.ww
%dir %{_localstatedir}/lib/warewulf/overlays/generic/etc/munge %dir %{_datadir}/warewulf/overlays/generic/etc/munge
%{_localstatedir}/lib/warewulf/overlays/generic/etc/munge/munge.key.ww %{_datadir}/warewulf/overlays/generic/etc/munge/munge.key.ww
%dir %attr(0700,munge,munge) %{_localstatedir}/lib/warewulf/overlays/generic/etc/munge %dir %attr(0700,munge,munge) %{_datadir}/warewulf/overlays/generic/etc/munge
%attr(0600,munge,munge) %config(noreplace) %{_localstatedir}/lib/warewulf/overlays/generic/etc/munge/munge.key.ww %attr(0600,munge,munge) %config(noreplace) %{_datadir}/warewulf/overlays/generic/etc/munge/munge.key.ww
%changelog %changelog