From ba0dec021aa3fdf43da4d7403e61f1e703ece852 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Fri, 10 Mar 2023 16:03:18 +0100 Subject: [PATCH 1/3] added experimental dnsmasq support Signed-off-by: Christian Goll --- CHANGELOG.md | 1 + overlays/host/dnsmasq.d/ww4-hosts.conf.ww | 30 +++++++++++++++++++++++ userdocs/contents/dnsmasq.rst | 17 +++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 overlays/host/dnsmasq.d/ww4-hosts.conf.ww create mode 100644 userdocs/contents/dnsmasq.rst diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c14ff8..17690640 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The primary hostname and warewulf server fqdn are now the canonical name in `/etc/hosts` +- Added experimental dnsmasq support. ## [4.4.0] 2023-01-18 diff --git a/overlays/host/dnsmasq.d/ww4-hosts.conf.ww b/overlays/host/dnsmasq.d/ww4-hosts.conf.ww new file mode 100644 index 00000000..a9d6d66f --- /dev/null +++ b/overlays/host/dnsmasq.d/ww4-hosts.conf.ww @@ -0,0 +1,30 @@ +# This file was autgenerated by warewulf +# Host: {{.BuildHost}} +# Time: {{.BuildTime}} +# Source {{.BuildSource}} +{{ nobackup }} +# select the x86 hosts which will get the iXPE binary +dhcp-match=set:x86PC,option:client-arch, 7 #EFI x86-64 +dhcp-match=set:x86PC,option:client-arch, 6 #EFI x86-64 +dhcp-match=set:x86PC,option:client-arch, 9 #EFI x86-64 +{{ with (index $.Tftp.IpxeBinaries "00:07" ) }}dhcp-boot=tag:x86PC,"/warewulf/{{ index $.Tftp.IpxeBinaries "00:07" }}"{{ end }} +dhcp-no-override +# iPXE binary will get the following configuration file +dhcp-userclass=set:iPXE,iPXE +dhcp-boot=tag:iPXE,"http://{{$.Ipaddr}}:{{$.Warewulf.Port}}/ipxe/${mac:hexhyp}" +{{- if $.Tftp.Enabled }} +# also act as tftp server +tftp-root={{ $.Tftp.TftpRoot }} +{{- end }} +# define the the range +dhcp-range={{$.Dhcp.RangeStart}},{{$.Dhcp.RangeEnd}},{{$.Netmask}},6h +{{/* Add all the known hosts */}} +{{- range $node := $.AllNodes}} {{/* for each node */}} +{{- range $devname, $netdev := $node.NetDevs}} {{/* for each network device on the node */}} +{{- if $netdev.Ipaddr.Defined}} {{/* if we have an ip address on this network device */}} +{{- if $netdev.Hwaddr.Defined }} +dhcp-host={{$netdev.Hwaddr.Get}},set:warewulf,{{$node.Id.Get}},{{$netdev.Ipaddr.Get}},infinite +{{- end}} {{/* end if Hwaddr */}} +{{- end}} {{/* end if ip */}} +{{- end}} {{/* end for each network device */}} +{{- end}} {{/* end for each node */}} diff --git a/userdocs/contents/dnsmasq.rst b/userdocs/contents/dnsmasq.rst new file mode 100644 index 00000000..e1b97486 --- /dev/null +++ b/userdocs/contents/dnsmasq.rst @@ -0,0 +1,17 @@ +======= +Dnsmasq +======= + +Usage +===== + +As experimental feature its possible to use `dnsmasq` instead of the ISC `dhcpd` server in combination +with a `tFTP` server. The `dnsmasq` service is then acting as `dhcp` and `tftp` server. In order to keep +the file `/etc/dnsmasq.d/ww4-hosts.conf` is created and must be included in the main `dnsmasq.conf` via +the `conf-dir=/etc/dnsmasq.d` option. + +Addionally in the configuration file `warewulf.conf` in the sections `dhcp` and `tftp` the systemd name of +dnsmasq must set for the option `systemd name`. + +After this configuration steps its recommended to rebuild the host overlay with `wwctl overlay build -H` and +the the services should be configured with `wwctl configure -a`. From 84bfccba439dd2683787bf5abf1050758b592bec Mon Sep 17 00:00:00 2001 From: jason yang Date: Wed, 22 Mar 2023 04:18:50 +0000 Subject: [PATCH 2/3] add support for resolving absolute path automatically Signed-off-by: jason yang --- CHANGELOG.md | 1 + internal/pkg/api/container/container.go | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1017537..9e3db101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added a missing `.ww` extension to the `70-ww4-netname.rules` template in the wwinit overlay. - Restrict access to `/warewulf/config` to root only. (#728, #742) +- Add support for resolving absolute path automatically. #493 ### Changed diff --git a/internal/pkg/api/container/container.go b/internal/pkg/api/container/container.go index fdf720fd..5ae4347a 100644 --- a/internal/pkg/api/container/container.go +++ b/internal/pkg/api/container/container.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path" + "path/filepath" "strconv" "strings" @@ -18,7 +19,6 @@ import ( ) func ContainerBuild(cbp *wwapiv1.ContainerBuildParameter) (err error) { - if cbp == nil { return fmt.Errorf("ContainerBuildParameter is nil") } @@ -60,7 +60,7 @@ func ContainerBuild(cbp *wwapiv1.ContainerBuildParameter) (err error) { return } - //TODO: Don't loop through profiles, instead have a nodeDB function that goes directly to the map + // TODO: Don't loop through profiles, instead have a nodeDB function that goes directly to the map profiles, _ := nodeDB.FindAllProfiles() for _, profile := range profiles { wwlog.Debug("Looking for profile default: %s", profile.Id.Get()) @@ -85,7 +85,6 @@ func ContainerBuild(cbp *wwapiv1.ContainerBuildParameter) (err error) { } func ContainerDelete(cdp *wwapiv1.ContainerDeleteParameter) (err error) { - if cdp == nil { return fmt.Errorf("ContainerDeleteParameter is nil") } @@ -132,7 +131,6 @@ ARG_LOOP: } func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName string, err error) { - if cip == nil { err = fmt.Errorf("NodeAddParameter is nil") return @@ -176,6 +174,14 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin // TODO: mhink - return was missing here. Was that deliberate? } + if util.IsFile(cip.Source) && !filepath.IsAbs(cip.Source) { + cip.Source, err = filepath.Abs(cip.Source) + if err != nil { + err = fmt.Errorf("when resolving absolute path of %s, err: %v", cip.Source, err) + wwlog.Error(err.Error()) + return + } + } err = container.ImportDocker(cip.Source, cip.Name, sCtx) if err != nil { err = fmt.Errorf("could not import image: %s", err.Error()) @@ -221,7 +227,7 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin return } - //TODO: Don't loop through profiles, instead have a nodeDB function that goes directly to the map + // TODO: Don't loop through profiles, instead have a nodeDB function that goes directly to the map profiles, _ := nodeDB.FindAllProfiles() for _, profile := range profiles { wwlog.Debug("Looking for profile default: %s", profile.Id.Get()) @@ -332,7 +338,6 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) { } func ContainerShow(csp *wwapiv1.ContainerShowParameter) (response *wwapiv1.ContainerShowResponse, err error) { - containerName := csp.ContainerName if !container.ValidName(containerName) { From 6b40112175e09c2528e9c93505cd5e13e92edd3c Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Wed, 22 Mar 2023 21:13:00 +0100 Subject: [PATCH 3/3] use union strategy for CHANGELOG.md Signed-off-by: Christian Goll --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..a19ade07 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +CHANGELOG.md merge=union