diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c7369ff..8efcb9148 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,11 +40,14 @@ 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 +- Add iPXE template `dracut.ipxe` to boot a dracut initramfs. #1115 +- Add `.NetDevs` variable to iPXE templates, similar to overlay templates. #1115 ### Changed - Replace reference to docusaurus with Sphinx - `wwctl container import` now only runs syncuser if explicitly requested. #1212 +- wwinit now configures NetworkManager to not retain configurations from dracut. #1115 ### Fixed diff --git a/etc/ipxe/dracut.ipxe b/etc/ipxe/dracut.ipxe new file mode 100644 index 000000000..4336b01ec --- /dev/null +++ b/etc/ipxe/dracut.ipxe @@ -0,0 +1,46 @@ +#!ipxe + +echo +echo ================================================================================ +echo Warewulf v4 now booting via dracut: {{.Fqdn}} ({{.Hwaddr}}) +echo +echo Container: {{.ContainerName}} +{{if .KernelOverride }} +echo Kernel: {{.KernelOverride}} +{{else}} +echo Kernel: {{.ContainerName}} (container default) +{{end}} +echo KernelArgs: {{.KernelArgs}} +echo + +set uri http://{{.Ipaddr}}:{{.Port}}/provision/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} +echo Warewulf Controller: {{.Ipaddr}} + +echo Downloading Kernel Image: +kernel --name kernel ${uri}&stage=kernel || goto reboot + +{{if ne .KernelOverride ""}} +echo Downloading Kernel Modules: +imgextract --name kmods ${uri}&stage=kmods&compress=gz || initrd --name kmods ${uri}&stage=kmods || goto reboot +set kernel_mods initrd=kmods +{{end}} + +echo Downloading initramfs +initrd --name initramfs ${uri}&stage=initramfs || goto reboot + +set dracut_net rd.neednet=1 {{range $devname, $netdev := .NetDevs}}{{if and $netdev.Hwaddr $netdev.Device}} ifname={{$netdev.Device}}:{{$netdev.Hwaddr}} {{end}}{{end}} +set dracut_wwinit root=wwinit wwinit.container=${uri}&stage=container&compress=gz wwinit.system=${uri}&stage=system&compress=gz wwinit.runtime=${uri}&stage=runtime&compress=gz {{if ne .KernelOverride ""}}wwinit.kmods=${uri}&stage=kmods&compress=gz{{end}} init=/init + +echo Booting initramfs +#echo Network KernelArgs: ${dracut_net} +#echo Dracut wwinit KernelArgs: ${dracut_wwinit} +#sleep 15 +boot kernel initrd=initramfs ${kernel_mods} ${dracut_net} ${dracut_wwinit} wwid={{.Hwaddr}} {{.KernelArgs}} + + +:reboot +echo +echo There was an error, rebooting in 15s... +echo +sleep 15 +reboot diff --git a/internal/pkg/warewulfd/provision.go b/internal/pkg/warewulfd/provision.go index 8861cd999..9ef089ba8 100644 --- a/internal/pkg/warewulfd/provision.go +++ b/internal/pkg/warewulfd/provision.go @@ -15,6 +15,7 @@ import ( warewulfconf "github.com/warewulf/warewulf/internal/pkg/config" "github.com/warewulf/warewulf/internal/pkg/container" "github.com/warewulf/warewulf/internal/pkg/kernel" + "github.com/warewulf/warewulf/internal/pkg/node" "github.com/warewulf/warewulf/internal/pkg/overlay" "github.com/warewulf/warewulf/internal/pkg/util" "github.com/warewulf/warewulf/internal/pkg/wwlog" @@ -33,6 +34,7 @@ type templateVars struct { Port string KernelArgs string KernelOverride string + NetDevs map[string]*node.NetDevs } func ProvisionSend(w http.ResponseWriter, req *http.Request) { @@ -94,6 +96,7 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) { } else if rinfo.stage == "ipxe" { stage_file = path.Join(conf.Paths.Sysconfdir, "warewulf/ipxe/"+node.Ipxe.Get()+".ipxe") + tstruct := overlay.InitStruct(&node) tmpl_data = templateVars{ Id: node.Id.Get(), Cluster: node.ClusterName.Get(), @@ -104,7 +107,8 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) { Hwaddr: rinfo.hwaddr, ContainerName: node.ContainerName.Get(), KernelArgs: node.Kernel.Args.Get(), - KernelOverride: node.Kernel.Override.Get()} + KernelOverride: node.Kernel.Override.Get(), + NetDevs: tstruct.NetDevs} } else if rinfo.stage == "kernel" { if node.Kernel.Override.Defined() { stage_file = kernel.KernelImage(node.Kernel.Override.Get()) diff --git a/overlays/wwinit/rootfs/etc/NetworkManager/conf.d/ww4-discard-configuration.conf b/overlays/wwinit/rootfs/etc/NetworkManager/conf.d/ww4-discard-configuration.conf new file mode 100644 index 000000000..8a7b064a1 --- /dev/null +++ b/overlays/wwinit/rootfs/etc/NetworkManager/conf.d/ww4-discard-configuration.conf @@ -0,0 +1,2 @@ +[device] +keep-configuration=no