Extend and optimize relocatable build config infrastructure

This commit is contained in:
Gregory Kurtzer
2022-01-15 03:32:32 +00:00
parent be41b79261
commit 8da7dd415a
23 changed files with 258 additions and 348 deletions

5
.gitignore vendored
View File

@@ -18,3 +18,8 @@
/etc/bash_completion.d/ /etc/bash_completion.d/
/etc/warewulf.conf /etc/warewulf.conf
warewulf.spec warewulf.spec
internal/pkg/buildconfig/buildconfig.go
include/systemd/warewulfd.service
_dist/
config
warewulf-*.tar.gz

154
Makefile
View File

@@ -3,20 +3,35 @@
VERSION ?= 4.2.0 VERSION ?= 4.2.0
RELEASE ?= 1 RELEASE ?= 1
SRC ?= main SRC ?= HEAD
VERSION_FULL ?= $(shell test -e .git && git describe --tags --long --first-parent --always) VERSION_FULL ?= $(shell test -e .git && git describe --tags --long --first-parent --always)
ifeq ($(VERSION_FULL),) ifeq ($(VERSION_FULL),)
VERSION_FULL := $(VERSION) VERSION_FULL := $(VERSION)
endif endif
WWROOT ?= /var/lib # System locations
# warewulf subdir automatcally added to TFTPROOT PREFIX ?= /usr/local
TFTPROOT ?= /var/lib/tftpboot BINDIR ?= $(PREFIX)/bin
# SUSE: TFTPROOT ?= /srv/tftpboot SYSCONFDIR ?= $(PREFIX)/etc
# Ubuntu: TFTPROOT ?= /srv/tftp SRVDIR ?= $(PREFIX)/srv
FIREWALLDIR ?= /usr/lib/firewalld/services SHAREDIR ?= $(PREFIX)/share
OVERLAYDIR ?= $(WWROOT)/warewulf/overlays MANDIR ?= $(SHAREDIR)/man
LOCALSTATEDIR ?= $(PREFIX)/var
TFTPDIR ?= /var/lib/tftpboot
FIREWALLDDIR ?= /usr/lib/firewalld/services
SYSTEMDDIR ?= /usr/lib/systemd/system
BASH_COMPLETION ?= /etc/bash_completion.d/
# Warewulf locations
WWPROVISIONDIR ?= $(SRVDIR)/warewulf
WWOVERLAYDIR ?= $(LOCALSTATEDIR)/warewulf/overlays
WWCHROOTDIR ?= $(LOCALSTATEDIR)/warewulf/chroots
# SuSE
#TFTPDIR ?= /srv/tftpboot
#FIREWALLDIR ?= /srv/tftp
# auto installed tooling # auto installed tooling
TOOLS_DIR := .tools TOOLS_DIR := .tools
@@ -64,8 +79,23 @@ $(TOOLS_DIR):
# Pre-build steps for source, such as "go generate" # Pre-build steps for source, such as "go generate"
config: config:
sed -e 's,@WWROOT@,$(WWROOT),g; s,@VERSION@,$(VERSION),g; s,@RELEASE@,$(RELEASE),g' warewulf.spec.in > warewulf.spec set -x ;\
sed -e 's,@WWROOT@,$(WWROOT),g; s,@TFTPROOT@,$(TFTPROOT),g' etc/warewulf.conf.in > etc/warewulf.conf for i in `find . -type f -name "*.in" -not -path "./vendor/*"`; do \
NAME=`echo $$i | sed -e 's,\.in,,'`; \
sed -e 's,@BINDIR@,$(BINDIR),g' \
-e 's,@SYSCONFDIR@,$(SYSCONFDIR),g' \
-e 's,@LOCALSTATEDIR@,$(LOCALSTATEDIR),g' \
-e 's,@SRVDIR@,$(SRVDIR),g' \
-e 's,@TFTPDIR@,$(TFTPDIR),g' \
-e 's,@FIREWALLDDIR@,$(FIREWALLDDIR),g' \
-e 's,@SYSTEMDDIR@,$(SYSTEMDDIR),g' \
-e 's,@WWOVERLAYDIR@,$(WWOVERLAYDIR),g' \
-e 's,@WWCHROOTDIR@,$(WWCHROOTDIR),g' \
-e 's,@WWPROVISIONDIR@,$(WWPROVISIONDIR),g' \
-e 's,@VERSION@,$(VERSION),g' \
-e 's,@RELEASE@,$(RELEASE),g' $$i > $$NAME; \
done
touch config
# Lint # Lint
lint: setup_tools config lint: setup_tools config
@@ -91,63 +121,60 @@ test-cover: ## Run test coverage and generate html report
debian: all debian: all
files: all files: all
install -d -m 0755 $(DESTDIR)/usr/bin/ install -d -m 0755 $(DESTDIR)$(BINDIR)
install -d -m 0755 $(DESTDIR)$(WWROOT)/warewulf/ install -d -m 0755 $(DESTDIR)$(WWCHROOTDIR)
install -d -m 0755 $(DESTDIR)$(WWROOT)/warewulf/chroots install -d -m 0755 $(DESTDIR)$(WWPROVISIONDIR)
install -d -m 0755 $(DESTDIR)$(WWROOT)/warewulf/provision install -d -m 0755 $(DESTDIR)$(WWOVERLAYDIR)
install -d -m 0755 $(DESTDIR)/etc/warewulf/ install -d -m 0755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/bin/
install -d -m 0755 $(DESTDIR)/etc/warewulf/ipxe install -d -m 0755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/warewulf/bin/
install -d -m 0755 $(DESTDIR)$(TFTPROOT)/warewulf/ipxe/ install -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/warewulf/
install -d -m 0755 $(DESTDIR)/etc/bash_completion.d/ install -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/warewulf/ipxe
install -d -m 0755 $(DESTDIR)/usr/share/man/man1 install -d -m 0755 $(DESTDIR)$(TFTPDIR)/warewulf/ipxe/
test -f $(DESTDIR)/etc/warewulf/warewulf.conf || install -m 644 etc/warewulf.conf $(DESTDIR)/etc/warewulf/ install -d -m 0755 $(DESTDIR)$(BASH_COMPLETION)
test -f $(DESTDIR)/etc/warewulf/hosts.tmpl || install -m 644 etc/hosts.tmpl $(DESTDIR)/etc/warewulf/ install -d -m 0755 $(DESTDIR)$(SHAREDIR)/man/man1
test -f $(DESTDIR)/etc/warewulf/nodes.conf || install -m 644 etc/nodes.conf $(DESTDIR)/etc/warewulf/ install -d -m 0755 $(DESTDIR)$(FIREWALLDDIR)
cp -r etc/dhcp $(DESTDIR)/etc/warewulf/ install -d -m 0755 $(DESTDIR)$(SYSTEMDDIR)
cp -r etc/ipxe $(DESTDIR)/etc/warewulf/ test -f $(DESTDIR)$(SYSCONFDIR)/warewulf/warewulf.conf || install -m 644 etc/warewulf.conf $(DESTDIR)$(SYSCONFDIR)/warewulf/
mkdir -p $(DESTDIR)$(OVERLAYDIR) test -f $(DESTDIR)$(SYSCONFDIR)/warewulf/hosts.tmpl || install -m 644 etc/hosts.tmpl $(DESTDIR)$(SYSCONFDIR)/warewulf/
cp -r overlays/* $(DESTDIR)$(OVERLAYDIR)/ test -f $(DESTDIR)$(SYSCONFDIR)/warewulf/nodes.conf || install -m 644 etc/nodes.conf $(DESTDIR)$(SYSCONFDIR)/warewulf/
mkdir -p $(DESTDIR)$(OVERLAYDIR)/wwinit/bin/ cp -r etc/dhcp $(DESTDIR)$(SYSCONFDIR)/warewulf/
mkdir -p $(DESTDIR)$(OVERLAYDIR)/wwinit/warewulf/bin/ cp -r etc/ipxe $(DESTDIR)$(SYSCONFDIR)/warewulf/
chmod +x $(DESTDIR)$(OVERLAYDIR)/wwinit/init cp -r overlays/* $(DESTDIR)$(WWOVERLAYDIR)/
chmod 600 $(DESTDIR)$(OVERLAYDIR)/wwinit/etc/ssh/ssh* chmod 755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/init
chmod 644 $(DESTDIR)$(OVERLAYDIR)/wwinit/etc/ssh/ssh*.pub.ww chmod 600 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/ssh/ssh*
mkdir -p $(DESTDIR)$(OVERLAYDIR)/wwinit/warewulf/bin/ chmod 644 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/ssh/ssh*.pub.ww
install -m 0755 wwctl $(DESTDIR)/usr/bin/ install -m 0755 wwctl $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(FIREWALLDIR) install -c -m 0644 include/firewalld/warewulf.xml $(DESTDIR)$(FIREWALLDDIR)
install -c -m 0644 include/firewalld/warewulf.xml $(DESTDIR)$(FIREWALLDIR) install -c -m 0644 include/systemd/warewulfd.service $(DESTDIR)$(SYSTEMDDIR)
mkdir -p $(DESTDIR)/usr/lib/systemd/system cp bash_completion.d/warewulf $(DESTDIR)$(BASH_COMPLETION)
install -c -m 0644 include/systemd/warewulfd.service $(DESTDIR)/usr/lib/systemd/system cp man_pages/* $(DESTDIR)$(MANDIR)/man1/
cp bash_completion.d/warewulf $(DESTDIR)/etc/bash_completion.d/
cp man_pages/* $(DESTDIR)/usr/share/man/man1/
init: init:
systemctl daemon-reload systemctl daemon-reload
cp -r tftpboot/* $(TFTPROOT)/warewulf/ipxe/ cp -r tftpboot/* $(TFTPDIR)/warewulf/ipxe/
restorecon -r $(TFTPROOT)/warewulf restorecon -r $(TFTPDIR)/warewulf
debfiles: debian # Overlay file system has changed
chmod +x $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/init #debfiles: debian
chmod 600 $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/etc/ssh/ssh* # chmod +x $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/init
chmod 644 $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/etc/ssh/ssh*.pub.ww # chmod 600 $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/etc/ssh/ssh*
mkdir -p $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/warewulf/bin/ # chmod 644 $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/etc/ssh/ssh*.pub.ww
cp wwclient $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/warewulf/bin/ # mkdir -p $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/warewulf/bin/
# cp wwclient $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/warewulf/bin/
wwctl: wwctl:
cd cmd/wwctl; GOOS=linux go build \ cd cmd/wwctl; GOOS=linux go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../wwctl
-ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/version.Version=$(VERSION_FULL)' \
-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.defaultDataStore=$(WWROOT)/warewulf'" \
-mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../wwctl
wwclient: wwclient:
cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags '-extldflags -static' -o ../../wwclient cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags '-extldflags -static' -o ../../wwclient
install_wwclient: wwclient install_wwclient: wwclient
install -m 0755 wwclient $(DESTDIR)$(WWROOT)/warewulf/overlays/wwinit/bin/wwclient install -m 0755 wwclient $(DESTDIR)$(WWOVERLAYDIR)/wwinit/bin/wwclient
bash_completion: bash_completion:
cd cmd/bash_completion && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=$(CONFIG)/etc/warewulf.conf'\ cd cmd/bash_completion && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=./etc/warewulf.conf'\
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=$(CONFIG)/etc/nodes.conf'"\ -X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf'"\
-mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../bash_completion -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../bash_completion
bash_completion.d: bash_completion bash_completion.d: bash_completion
@@ -155,8 +182,8 @@ bash_completion.d: bash_completion
./bash_completion bash_completion.d/warewulf ./bash_completion bash_completion.d/warewulf
man_page: man_page:
cd cmd/man_page && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=$(CONFIG)/etc/warewulf.conf'\ cd cmd/man_page && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=./etc/warewulf.conf'\
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=$(CONFIG)/etc/nodes.conf'"\ -X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf'"\
-mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../man_page -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../man_page
man_pages: man_page man_pages: man_page
@@ -164,13 +191,13 @@ man_pages: man_page
./man_page ./man_pages ./man_page ./man_pages
cd man_pages; for i in wwctl*1; do echo "Compressing manpage: $$i"; gzip --force $$i; done cd man_pages; for i in wwctl*1; do echo "Compressing manpage: $$i"; gzip --force $$i; done
config_defaults: #config_defaults:
cd cmd/config_defaults && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=$(CONFIG)/etc/warewulf.conf' \ # cd cmd/config_defaults && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=./etc/warewulf.conf' \
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=$(CONFIG)/etc/nodes.conf' \ # -X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf' \
-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.defaultDataStore=$(WWROOT)/warewulf'" \ # -X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.defaultDataStore=$(WWROOT)/warewulf'" \
-mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../config_defaults # -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../config_defaults
dist: vendor dist: vendor config
rm -rf _dist/warewulf-$(VERSION) rm -rf _dist/warewulf-$(VERSION)
mkdir -p _dist/warewulf-$(VERSION) mkdir -p _dist/warewulf-$(VERSION)
git archive --format=tar $(SRC) | tar -xf - -C _dist/warewulf-$(VERSION) git archive --format=tar $(SRC) | tar -xf - -C _dist/warewulf-$(VERSION)
@@ -188,7 +215,8 @@ clean:
rm -f man_page rm -f man_page
rm -rf man_pages rm -rf man_pages
rm -rf vendor rm -rf vendor
rm -f config_defaults # rm -f config_defaults
rm -f config
install: files install_wwclient install: files install_wwclient

View File

@@ -6,7 +6,7 @@ warewulf:
autobuild overlays: true autobuild overlays: true
update interval: 60 update interval: 60
syslog: false syslog: false
datastore: @WWROOT@/warewulf datastore: @WWPROVISIONDIR@
dhcp: dhcp:
enabled: true enabled: true
range start: 192.168.200.50 range start: 192.168.200.50
@@ -15,7 +15,7 @@ dhcp:
systemd name: dhcpd systemd name: dhcpd
tftp: tftp:
enabled: true enabled: true
tftproot: @TFTPROOT@ tftproot: @TFTPDIR@
systemd name: tftp systemd name: tftp
nfs: nfs:
systemd name: nfs-server systemd name: nfs-server

View File

@@ -2,14 +2,14 @@
Description=Warewulf cluster management daemon Description=Warewulf cluster management daemon
Documentation=https://warewulf.hpcng.org/ Documentation=https://warewulf.hpcng.org/
After=network-online.target After=network-online.target
AssertFileIsExecutable=/usr/bin/wwctl AssertFileIsExecutable=@BINDIR@/wwctl
[Service] [Service]
Type=forking Type=forking
User=root User=root
Group=root Group=root
ExecStart=/usr/bin/wwctl server start ExecStart=@BINDIR@/wwctl server start
PIDFile=/var/run/warewulfd.pid PIDFile=/var/run/warewulfd.pid
Restart=always Restart=always

View File

@@ -8,6 +8,7 @@ import (
"strings" "strings"
"text/template" "text/template"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
@@ -84,12 +85,12 @@ func Configure(show bool) error {
d.Nodes = append(d.Nodes, nodes...) d.Nodes = append(d.Nodes, nodes...)
if controller.Dhcp.Template == "" { if controller.Dhcp.Template == "" {
templateFile = "/etc/warewulf/dhcp/default-dhcpd.conf" templateFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/dhcp/default-dhcpd.conf")
} else { } else {
if strings.HasPrefix(controller.Dhcp.Template, "/") { if strings.HasPrefix(controller.Dhcp.Template, "/") {
templateFile = controller.Dhcp.Template templateFile = controller.Dhcp.Template
} else { } else {
templateFile = fmt.Sprintf("/etc/warewulf/dhcp/%s-dhcpd.conf", controller.Dhcp.Template) templateFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/dhcp/"+controller.Dhcp.Template+"dhcpd.conf")
} }
} }

View File

@@ -3,8 +3,10 @@ package hosts
import ( import (
"bytes" "bytes"
"os" "os"
"path"
"text/template" "text/template"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
@@ -26,7 +28,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
func Configure(show bool) error { func Configure(show bool) error {
var replace TemplateStruct var replace TemplateStruct
if !util.IsFile("/etc/warewulf/hosts.tmpl") { if !util.IsFile(path.Join(buildconfig.SYSCONFDIR, "warewulf/hosts.tmpl")) {
wwlog.Printf(wwlog.WARN, "Template not found, not updating host file\n") wwlog.Printf(wwlog.WARN, "Template not found, not updating host file\n")
return nil return nil
} }
@@ -43,7 +45,7 @@ func Configure(show bool) error {
os.Exit(1) os.Exit(1)
} }
tmpl, err := template.ParseFiles("/etc/warewulf/hosts.tmpl") tmpl, err := template.ParseFiles(path.Join(buildconfig.SYSCONFDIR, "warewulf/hosts.tmpl"))
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not parse hosts template: %s\n", err) wwlog.Printf(wwlog.ERROR, "Could not parse hosts template: %s\n", err)
os.Exit(1) os.Exit(1)

View File

@@ -101,7 +101,7 @@ func Configure(show bool) error {
fmt.Printf("%s %s/%s\n", export.Path, controller.Network, controller.Netmask) fmt.Printf("%s %s/%s\n", export.Path, controller.Network, controller.Netmask)
} }
fmt.Printf("\n") fmt.Printf("\n")
fmt.Printf("SYSTEM OVERLAY: default/etc/fstab:\n") fmt.Printf("SYSTEM OVERLAY: wwinit/etc/fstab:\n")
for _, export := range controller.Nfs.Exports { for _, export := range controller.Nfs.Exports {
fmt.Printf("%s:%s %s nfs defaults 0 0\n", controller.Ipaddr, export, export) fmt.Printf("%s:%s %s nfs defaults 0 0\n", controller.Ipaddr, export, export)
} }

View File

@@ -5,6 +5,7 @@ import (
"os" "os"
"path" "path"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors" "github.com/pkg/errors"
@@ -19,15 +20,17 @@ func Configure(show bool) error {
if os.Getuid() == 0 { if os.Getuid() == 0 {
fmt.Printf("Updating system keys\n") fmt.Printf("Updating system keys\n")
err := os.MkdirAll("/etc/warewulf/keys", 0755) wwkeydir := path.Join(buildconfig.SYSCONFDIR, "/etc/warewulf/keys") + "/"
err := os.MkdirAll(path.Join(buildconfig.SYSCONFDIR, "warewulf/keys"), 0755)
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not create base directory: %s\n", err) wwlog.Printf(wwlog.ERROR, "Could not create base directory: %s\n", err)
os.Exit(1) os.Exit(1)
} }
if !util.IsFile("/etc/warewulf/keys/ssh_host_rsa_key") { if !util.IsFile(wwkeydir + "ssh_host_rsa_key") {
fmt.Printf("Setting up key: ssh_host_rsa_key\n") fmt.Printf("Setting up key: ssh_host_rsa_key\n")
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "rsa", "-f", "/etc/warewulf/keys/ssh_host_rsa_key", "-C", "", "-N", "") err = util.ExecInteractive("ssh-keygen", "-q", "-t", "rsa", "-f", wwkeydir+"ssh_host_rsa_key", "-C", "", "-N", "")
if err != nil { if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command") return errors.Wrap(err, "failed to exec ssh-keygen command")
} }
@@ -35,9 +38,9 @@ func Configure(show bool) error {
fmt.Printf("Skipping, key already exists: ssh_host_rsa_key\n") fmt.Printf("Skipping, key already exists: ssh_host_rsa_key\n")
} }
if !util.IsFile("/etc/warewulf/keys/ssh_host_dsa_key") { if !util.IsFile(wwkeydir + "ssh_host_dsa_key") {
fmt.Printf("Setting up key: ssh_host_dsa_key\n") fmt.Printf("Setting up key: ssh_host_dsa_key\n")
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "dsa", "-f", "/etc/warewulf/keys/ssh_host_dsa_key", "-C", "", "-N", "") err = util.ExecInteractive("ssh-keygen", "-q", "-t", "dsa", "-f", wwkeydir+"ssh_host_dsa_key", "-C", "", "-N", "")
if err != nil { if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command") return errors.Wrap(err, "failed to exec ssh-keygen command")
} }
@@ -45,9 +48,9 @@ func Configure(show bool) error {
fmt.Printf("Skipping, key already exists: ssh_host_dsa_key\n") fmt.Printf("Skipping, key already exists: ssh_host_dsa_key\n")
} }
if !util.IsFile("/etc/warewulf/keys/ssh_host_ecdsa_key") { if !util.IsFile(wwkeydir + "ssh_host_ecdsa_key") {
fmt.Printf("Setting up key: ssh_host_ecdsa_key\n") fmt.Printf("Setting up key: ssh_host_ecdsa_key\n")
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ecdsa", "-f", "/etc/warewulf/keys/ssh_host_ecdsa_key", "-C", "", "-N", "") err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ecdsa", "-f", wwkeydir+"ssh_host_ecdsa_key", "-C", "", "-N", "")
if err != nil { if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command") return errors.Wrap(err, "failed to exec ssh-keygen command")
} }
@@ -55,9 +58,9 @@ func Configure(show bool) error {
fmt.Printf("Skipping, key already exists: ssh_host_ecdsa_key\n") fmt.Printf("Skipping, key already exists: ssh_host_ecdsa_key\n")
} }
if !util.IsFile("/etc/warewulf/keys/ssh_host_ed25519_key") { if !util.IsFile(wwkeydir + "ssh_host_ed25519_key") {
fmt.Printf("Setting up key: ssh_host_ed25519_key\n") fmt.Printf("Setting up key: ssh_host_ed25519_key\n")
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ed25519", "-f", "/etc/warewulf/keys/ssh_host_ed25519_key", "-C", "", "-N", "") err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ed25519", "-f", wwkeydir+"ssh_host_ed25519_key", "-C", "", "-N", "")
if err != nil { if err != nil {
return errors.Wrap(err, "failed to exec ssh-keygen command") return errors.Wrap(err, "failed to exec ssh-keygen command")
} }

View File

@@ -5,6 +5,7 @@ import (
"os" "os"
"path" "path"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/staticfiles" "github.com/hpcng/warewulf/internal/pkg/staticfiles"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
@@ -23,40 +24,35 @@ func Configure(show bool) error {
os.Exit(1) os.Exit(1)
} }
if controller.Tftp.TftpRoot == "" { if buildconfig.TFTPDIR == "" {
wwlog.Printf(wwlog.ERROR, "Tftp root directory is not configured in warewulfd.conf\n") wwlog.Printf(wwlog.ERROR, "Tftp root directory is not configured by build\n")
os.Exit(1) os.Exit(1)
} }
if !util.IsDir(controller.Tftp.TftpRoot) { err = os.MkdirAll(path.Join(buildconfig.TFTPDIR, "warewulf"), 0755)
wwlog.Printf(wwlog.ERROR, "Configured TFTP Root directory does not exist: %s\n", controller.Tftp.TftpRoot)
os.Exit(1)
}
err = os.MkdirAll(path.Join(controller.Tftp.TftpRoot, "warewulf"), 0755)
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err) wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1) os.Exit(1)
} }
if !show { if !show {
fmt.Printf("Writing PXE files to: %s\n", path.Join(controller.Tftp.TftpRoot, "warewulf")) fmt.Printf("Writing PXE files to: %s\n", path.Join(buildconfig.TFTPDIR, "warewulf"))
err = staticfiles.WriteData("files/tftp/x86.efi", path.Join(controller.Tftp.TftpRoot, "warewulf/x86.efi")) err = staticfiles.WriteData("files/tftp/x86.efi", path.Join(buildconfig.TFTPDIR, "warewulf/x86.efi"))
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err) wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1) os.Exit(1)
} }
err = staticfiles.WriteData("files/tftp/i386.efi", path.Join(controller.Tftp.TftpRoot, "warewulf/i386.efi")) err = staticfiles.WriteData("files/tftp/i386.efi", path.Join(buildconfig.TFTPDIR, "warewulf/i386.efi"))
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err) wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1) os.Exit(1)
} }
err = staticfiles.WriteData("files/tftp/i386.kpxe", path.Join(controller.Tftp.TftpRoot, "warewulf/i386.kpxe")) err = staticfiles.WriteData("files/tftp/i386.kpxe", path.Join(buildconfig.TFTPDIR, "warewulf/i386.kpxe"))
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err) wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1) os.Exit(1)
} }
err = staticfiles.WriteData("files/tftp/arm64.efi", path.Join(controller.Tftp.TftpRoot, "warewulf/arm64.efi")) err = staticfiles.WriteData("files/tftp/arm64.efi", path.Join(buildconfig.TFTPDIR, "warewulf/arm64.efi"))
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err) wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1) os.Exit(1)

View File

@@ -1,88 +0,0 @@
package ready
import (
"fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/kernel"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
n, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
os.Exit(1)
}
nodes, err := n.FindAllNodes()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not get node list: %s\n", err)
os.Exit(1)
}
fmt.Printf("%-25s %-10s %-6s %-6s %-6s %-6s %-6s\n", "NODE NAME", "STATUS", "VNFS", "KERNEL", "KMODS", "SYS-OL", "RUN-OL")
for _, node := range nodes {
var vnfs_good bool
var kernel_good bool
var kmods_good bool
var systemo_good bool
var runtimeo_good bool
status := true
if node.ContainerName.Get() != "" {
vnfsImage := container.ImageFile(node.ContainerName.Get())
if util.IsFile(vnfsImage) {
vnfs_good = true
} else {
status = false
wwlog.Printf(wwlog.VERBOSE, "VNFS not found: %s, %s\n", node.Id.Get(), vnfsImage)
}
} else {
status = false
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not defined: %s\n", node.Id.Get())
}
if node.KernelVersion.Get() != "" {
if util.IsFile(kernel.KernelImage(node.KernelVersion.Get())) {
kernel_good = true
} else {
status = false
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not found: %s, %s\n", node.Id.Get(), node.KernelVersion.Get())
}
if util.IsFile(kernel.KmodsImage(node.KernelVersion.Get())) {
kmods_good = true
} else {
status = false
wwlog.Printf(wwlog.VERBOSE, "Node Kmods not found: %s, %s\n", node.Id.Get(), node.KernelVersion.Get())
}
} else {
status = false
wwlog.Printf(wwlog.VERBOSE, "Node Kernel version not defined: %s\n", node.Id.Get())
}
if node.SystemOverlay.Get() != "" {
if util.IsFile(overlay.SystemOverlayImage(node.Id.Get())) {
systemo_good = true
} else {
status = false
wwlog.Printf(wwlog.VERBOSE, "System Overlay not found: %s\n", overlay.SystemOverlayImage(node.Id.Get()))
}
} else {
status = false
wwlog.Printf(wwlog.VERBOSE, "System Overlay not defined: %s\n", node.Id.Get())
}
fmt.Printf("%-25s %-10t %-6t %-6t %-6t %-6t %-6t\n", node.Id.Get(), status, vnfs_good, kernel_good, kmods_good, systemo_good, runtimeo_good)
}
return nil
}

View File

@@ -1,34 +0,0 @@
package ready
import (
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
DisableFlagsInUseLine: true,
Use: "ready [OPTIONS]",
Short: "Warewulf status check",
Long: "Provides the current status of all Warewulf nodes.",
RunE: CobraRunE,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}
nodeDB, _ := node.New()
nodes, _ := nodeDB.FindAllNodes()
var node_names []string
for _, node := range nodes {
node_names = append(node_names, node.Id.Get())
}
return node_names, cobra.ShellCompDirectiveNoFileComp
},
}
)
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd
}

View File

@@ -5,7 +5,6 @@ import (
"github.com/hpcng/warewulf/internal/app/wwctl/node/console" "github.com/hpcng/warewulf/internal/app/wwctl/node/console"
"github.com/hpcng/warewulf/internal/app/wwctl/node/delete" "github.com/hpcng/warewulf/internal/app/wwctl/node/delete"
"github.com/hpcng/warewulf/internal/app/wwctl/node/list" "github.com/hpcng/warewulf/internal/app/wwctl/node/list"
"github.com/hpcng/warewulf/internal/app/wwctl/node/ready"
"github.com/hpcng/warewulf/internal/app/wwctl/node/sensors" "github.com/hpcng/warewulf/internal/app/wwctl/node/sensors"
"github.com/hpcng/warewulf/internal/app/wwctl/node/set" "github.com/hpcng/warewulf/internal/app/wwctl/node/set"
nodestatus "github.com/hpcng/warewulf/internal/app/wwctl/node/status" nodestatus "github.com/hpcng/warewulf/internal/app/wwctl/node/status"
@@ -30,7 +29,6 @@ func init() {
baseCmd.AddCommand(add.GetCommand()) baseCmd.AddCommand(add.GetCommand())
baseCmd.AddCommand(delete.GetCommand()) baseCmd.AddCommand(delete.GetCommand())
baseCmd.AddCommand(console.GetCommand()) baseCmd.AddCommand(console.GetCommand())
baseCmd.AddCommand(ready.GetCommand())
baseCmd.AddCommand(nodestatus.GetCommand()) baseCmd.AddCommand(nodestatus.GetCommand())
} }

View File

@@ -0,0 +1,16 @@
package buildconfig
const (
BINDIR = "@BINDIR@"
SYSCONFDIR = "@SYSCONFDIR@"
LOCALSTATEDIR = "@LOCALSTATEDIR@"
SRVDIR = "@SRVDIR@"
TFTPDIR = "@TFTPDIR@"
FIREWALLDDIR = "@FIREWALLDDIR@"
SYSTEMDDIR = "@SYSTEMDDIR@"
WWOVERLAYDIR = "@WWOVERLAYDIR@"
WWCHROOTDIR = "@WWCHROOTDIR@"
WWPROVISIONDIR = "@WWPROVISIONDIR@"
VERSION = "@VERSION@"
RELEASE = "@RELEASE@"
)

View File

@@ -0,0 +1,27 @@
package container
import (
"path"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
)
func SourceParentDir() string {
return buildconfig.WWCHROOTDIR
}
func SourceDir(name string) string {
return path.Join(SourceParentDir(), name)
}
func RootFsDir(name string) string {
return path.Join(SourceDir(name), "rootfs")
}
func ImageParentDir() string {
return path.Join(buildconfig.WWPROVISIONDIR, "container/")
}
func ImageFile(name string) string {
return path.Join(ImageParentDir(), name+".img.gz")
}

View File

@@ -3,11 +3,9 @@ package container
import ( import (
"io/ioutil" "io/ioutil"
"os" "os"
"path"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
@@ -20,26 +18,6 @@ func ValidName(name string) bool {
return true return true
} }
func SourceParentDir() string {
return path.Join(warewulfconf.DataStore(), "chroots")
}
func SourceDir(name string) string {
return path.Join(SourceParentDir(), name)
}
func RootFsDir(name string) string {
return path.Join(SourceDir(name), "rootfs")
}
func ImageParentDir() string {
return path.Join(warewulfconf.DataStore(), "provision/container/")
}
func ImageFile(name string) string {
return path.Join(ImageParentDir(), name+".img.gz")
}
func ListSources() ([]string, error) { func ListSources() ([]string, error) {
var ret []string var ret []string

View File

@@ -11,7 +11,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
@@ -26,8 +26,8 @@ var (
} }
) )
func ParentDir() string { func KernelImageTopDir() string {
return path.Join(warewulfconf.DataStore(), "provision/kernel") return path.Join(buildconfig.WWPROVISIONDIR, "kernel")
} }
func KernelImage(kernelName string) string { func KernelImage(kernelName string) string {
@@ -41,7 +41,7 @@ func KernelImage(kernelName string) string {
return "" return ""
} }
return path.Join(ParentDir(), kernelName, "vmlinuz") return path.Join(KernelImageTopDir(), kernelName, "vmlinuz")
} }
func GetKernelVersion(kernelName string) string { func GetKernelVersion(kernelName string) string {
@@ -49,7 +49,7 @@ func GetKernelVersion(kernelName string) string {
wwlog.Printf(wwlog.ERROR, "Kernel Name is not defined\n") wwlog.Printf(wwlog.ERROR, "Kernel Name is not defined\n")
return "" return ""
} }
kernelVersion, err := ioutil.ReadFile(path.Join(ParentDir(), kernelName, "version")) kernelVersion, err := ioutil.ReadFile(KernelVersionFile(kernelName))
if err != nil { if err != nil {
return "" return ""
} }
@@ -67,10 +67,10 @@ func KmodsImage(kernelName string) string {
return "" return ""
} }
return path.Join(ParentDir(), kernelName, "kmods.img") return path.Join(KernelImageTopDir(), kernelName, "kmods.img")
} }
func KernelVersion(kernelName string) string { func KernelVersionFile(kernelName string) string {
if kernelName == "" { if kernelName == "" {
wwlog.Printf(wwlog.ERROR, "Kernel Name is not defined\n") wwlog.Printf(wwlog.ERROR, "Kernel Name is not defined\n")
return "" return ""
@@ -81,20 +81,20 @@ func KernelVersion(kernelName string) string {
return "" return ""
} }
return path.Join(ParentDir(), kernelName, "version") return path.Join(KernelImageTopDir(), kernelName, "version")
} }
func ListKernels() ([]string, error) { func ListKernels() ([]string, error) {
var ret []string var ret []string
err := os.MkdirAll(ParentDir(), 0755) err := os.MkdirAll(KernelImageTopDir(), 0755)
if err != nil { if err != nil {
return ret, errors.New("Could not create Kernel parent directory: " + ParentDir()) return ret, errors.New("Could not create Kernel parent directory: " + KernelImageTopDir())
} }
wwlog.Printf(wwlog.DEBUG, "Searching for Kernel image directories: %s\n", ParentDir()) wwlog.Printf(wwlog.DEBUG, "Searching for Kernel image directories: %s\n", KernelImageTopDir())
kernels, err := ioutil.ReadDir(ParentDir()) kernels, err := ioutil.ReadDir(KernelImageTopDir())
if err != nil { if err != nil {
return ret, err return ret, err
} }
@@ -109,12 +109,12 @@ func ListKernels() ([]string, error) {
return ret, nil return ret, nil
} }
func Build(kernelVersion string, kernelName string, root string) (string, error) { func Build(kernelVersion, kernelName, root string) (string, error) {
kernelDrivers := path.Join(root, "/lib/modules/"+kernelVersion) kernelDrivers := path.Join(root, "/lib/modules/"+kernelVersion)
kernelDriversRelative := path.Join("/lib/modules/"+kernelVersion) kernelDriversRelative := path.Join("/lib/modules/" + kernelVersion)
kernelDestination := KernelImage(kernelName) kernelDestination := KernelImage(kernelName)
driversDestination := KmodsImage(kernelName) driversDestination := KmodsImage(kernelName)
versionDestination := KernelVersion(kernelName) versionDestination := KernelVersionFile(kernelName)
var kernelSource string var kernelSource string
// Create the destination paths just in case it doesn't exist // Create the destination paths just in case it doesn't exist
@@ -223,7 +223,7 @@ func Build(kernelVersion string, kernelName string, root string) (string, error)
} }
func DeleteKernel(name string) error { func DeleteKernel(name string) error {
fullPath := path.Join(ParentDir(), name) fullPath := path.Join(KernelImageTopDir(), name)
wwlog.Printf(wwlog.VERBOSE, "Removing path: %s\n", fullPath) wwlog.Printf(wwlog.VERBOSE, "Removing path: %s\n", fullPath)
return os.RemoveAll(fullPath) return os.RemoveAll(fullPath)

View File

@@ -3,14 +3,23 @@ package node
import ( import (
"errors" "errors"
"io/ioutil" "io/ioutil"
"path"
"sort" "sort"
"strings" "strings"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
var ConfigFile = "/etc/warewulf/nodes.conf" var ConfigFile string
func init() {
if ConfigFile == "" {
ConfigFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/nodes.conf")
}
}
func New() (nodeYaml, error) { func New() (nodeYaml, error) {
var ret nodeYaml var ret nodeYaml

View File

@@ -3,13 +3,11 @@ package overlay
import ( import (
"path" "path"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/hpcng/warewulf/internal/pkg/util"
) )
func OverlaySourceTopDir() string { func OverlaySourceTopDir() string {
return path.Join(warewulfconf.DataStore(), "overlays/") return buildconfig.WWOVERLAYDIR
} }
func OverlaySourceDir(overlayName string) string { func OverlaySourceDir(overlayName string) string {
@@ -17,68 +15,5 @@ func OverlaySourceDir(overlayName string) string {
} }
func OverlayImage(nodeName string, overlayName string) string { func OverlayImage(nodeName string, overlayName string) string {
return path.Join(warewulfconf.DataStore(), "/provision/overlays/", nodeName, overlayName + ".img") return path.Join(buildconfig.WWPROVISIONDIR, "overlays/", nodeName, overlayName+".img")
}
func SystemOverlayDir() string {
return path.Join(OverlaySourceTopDir(), "/system")
}
func RuntimeOverlayDir() string {
return path.Join(OverlaySourceTopDir(), "/runtime")
}
func SystemOverlaySource(overlayName string) string {
if overlayName == "" {
wwlog.Printf(wwlog.ERROR, "System overlay name is not defined\n")
return ""
}
if !util.ValidString(overlayName, "^[a-zA-Z0-9-._]+$") {
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", overlayName)
return ""
}
return path.Join(SystemOverlayDir(), overlayName)
}
func RuntimeOverlaySource(overlayName string) string {
if overlayName == "" {
wwlog.Printf(wwlog.ERROR, "Runtime overlay name is not defined\n")
return ""
}
if !util.ValidString(overlayName, "^[a-zA-Z0-9-._]+$") {
wwlog.Printf(wwlog.ERROR, "Runtime overlay name contains illegal characters: %s\n", overlayName)
return ""
}
return path.Join(RuntimeOverlayDir(), overlayName)
}
func SystemOverlayImage(nodeName string) string {
if nodeName == "" {
wwlog.Printf(wwlog.ERROR, "Node name is not defined\n")
return ""
}
if !util.ValidString(nodeName, "^[a-zA-Z0-9-._:]+$") {
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", nodeName)
return ""
}
return path.Join(warewulfconf.DataStore(), "/provision/overlays/runtime/", nodeName + ".img")
}
func RuntimeOverlayImage(nodeName string) string {
if nodeName == "" {
wwlog.Printf(wwlog.ERROR, "Node name is not defined\n")
return ""
}
if !util.ValidString(nodeName, "^[a-zA-Z0-9-._:]+$") {
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", nodeName)
return ""
}
return path.Join(warewulfconf.DataStore(), "/provision/overlays/system/", nodeName + ".img")
} }

View File

@@ -1,7 +1,11 @@
package version package version
var Version string = "development" import (
"fmt"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
)
func GetVersion() string { func GetVersion() string {
return Version return fmt.Sprintf("%s-%s", buildconfig.VERSION, buildconfig.RELEASE)
} }

View File

@@ -1,12 +1,14 @@
package warewulfconf package warewulfconf
import ( import (
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net" "net"
"errors" "path"
"github.com/brotherpowers/ipsubnet" "github.com/brotherpowers/ipsubnet"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
@@ -14,6 +16,14 @@ import (
var cachedConf ControllerConf var cachedConf ControllerConf
var ConfigFile string
func init() {
if ConfigFile == "" {
ConfigFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/warewulf.conf")
}
}
func New() (ControllerConf, error) { func New() (ControllerConf, error) {
var ret ControllerConf = *defaultConfig() var ret ControllerConf = *defaultConfig()
@@ -32,8 +42,8 @@ func New() (ControllerConf, error) {
return ret, err return ret, err
} }
// TODO: Need to add comprehensive config file validator // TODO: Need to add comprehensive config file validator
// TODO: Change function to guess default IP address and/or mask from local system // TODO: Change function to guess default IP address and/or mask from local system
if ret.Ipaddr == "" { if ret.Ipaddr == "" {
wwlog.Printf(wwlog.ERROR, "IP address is not configured in warewulfd.conf\n") wwlog.Printf(wwlog.ERROR, "IP address is not configured in warewulfd.conf\n")
return ret, errors.New("no IP Address") return ret, errors.New("no IP Address")

View File

@@ -1,11 +1,8 @@
package warewulfconf package warewulfconf
const defaultPort int = 9983 const defaultPort int = 9983
var ( var defaultDataStore string = "/var/lib/warewulf"
ConfigFile string = "/etc/warewulf/warewulf.conf"
defaultDataStore string = "/var/lib/warewulf"
)
func defaultConfig() *ControllerConf { func defaultConfig() *ControllerConf {
Warewulf := &WarewulfConf{ Warewulf := &WarewulfConf{
@@ -30,8 +27,8 @@ func defaultConfig() *ControllerConf {
SystemdName: "tftp", SystemdName: "tftp",
} }
Nfs := &NfsConf{ Nfs := &NfsConf{
Enabled: true, Enabled: true,
Exports: []string{"/home",}, Exports: []string{"/home"},
SystemdName: "nfs-server", SystemdName: "nfs-server",
} }

View File

@@ -1,12 +1,13 @@
package warewulfd package warewulfd
import ( import (
"fmt"
"net/http" "net/http"
"path"
"strconv" "strconv"
"strings" "strings"
"text/template" "text/template"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
@@ -100,7 +101,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
if unconfiguredNode { if unconfiguredNode {
daemonLogf("IPXEREQ: %s (unknown/unconfigured node)\n", hwaddr) daemonLogf("IPXEREQ: %s (unknown/unconfigured node)\n", hwaddr)
tmpl, err := template.ParseFiles("/etc/warewulf/ipxe/unconfigured.ipxe") tmpl, err := template.ParseFiles(path.Join(buildconfig.SYSCONFDIR, "/warewulf/ipxe/unconfigured.ipxe"))
if err != nil { if err != nil {
daemonLogf("ERROR: Could not parse unconfigured node IPXE template: %s\n", err) daemonLogf("ERROR: Could not parse unconfigured node IPXE template: %s\n", err)
return return
@@ -120,7 +121,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
} else { } else {
ipxeTemplate := fmt.Sprintf("/etc/warewulf/ipxe/%s.ipxe", nodeobj.Ipxe.Get()) ipxeTemplate := path.Join(buildconfig.SYSCONFDIR, "warewulf/ipxe/"+nodeobj.Ipxe.Get()+".ipxe")
tmpl, err := template.ParseFiles(ipxeTemplate) tmpl, err := template.ParseFiles(ipxeTemplate)
if err != nil { if err != nil {

View File

@@ -1,9 +1,10 @@
%global wwgroup warewulf %global wwgroup warewulf
%global wwshared @WWROOT@
%if 0%{?sle_version} %if 0%{?sle_version}
%global tftpdir "/srv/tftpboot" %global tftpdir "/srv/tftpboot"
%global srvdir "/srv"
%else %else
%global tftpdir "/var/lib/tftpboot" %global tftpdir "/var/lib/tftpboot"
%global srvdir "%{_localstatedir}/warewulf/srv"
%endif %endif
%define debug_package %{nil} %define debug_package %{nil}
@@ -13,7 +14,7 @@ Version: @VERSION@
Release: @RELEASE@%{?dist} Release: @RELEASE@%{?dist}
License: BSD-3-Clause License: BSD-3-Clause
URL: https://github.com/hpcng/warewulf URL: https://github.com/hpcng/warewulf
Source: https://github.com/hpcng/warewulf/archive/refs/tags/v%{version}.tar.gz Source: warewulf-%{version}.tar.gz
ExclusiveOS: linux ExclusiveOS: linux
@@ -56,11 +57,30 @@ system for large clusters of bare metal and/or virtual systems.
%build %build
make TFTPROOT="%{tftpdir}" WWROOT="%{wwshared}" make PREFIX=/usr \
SRVDIR=%{srvdir} \
LOCALSTATEDIR=%{_localstatedir} \
SYSCONFDIR=%{_sysconfdir} \
BINDIR=%{_bindir} \
TFTPDIR=%{tftpdir} \
SYSTEMDDIR=%{_unitdir} \
MANDIR=%{_mandir} \
BASH_COMPLETION=/etc/bash_completion.d/ \
FIREWALLDDIR=/usr/lib/firewalld/services \
DESTDIR=%{buildroot}
%install %install
%make_install DESTDIR=%{buildroot} TFTPROOT="%{tftpdir}" WWROOT="%{wwshared}" %{?mflags_install} make install PREFIX=/usr \
SRVDIR=%{srvdir} \
LOCALSTATEDIR=%{_localstatedir} \
SYSCONFDIR=%{_sysconfdir} \
BINDIR=%{_bindir} \
TFTPDIR=%{tftpdir} \
SYSTEMDDIR=%{_unitdir} \
MANDIR=%{_mandir} \
BASH_COMPLETION=/etc/bash_completion.d/ \
FIREWALLDDIR=/usr/lib/firewalld/services \
DESTDIR=%{buildroot}
%pre %pre
@@ -86,8 +106,10 @@ getent group %{wwgroup} >/dev/null || groupadd -r %{wwgroup}
%config(noreplace) %attr(0640,-,-) %{_sysconfdir}/%{name}/nodes.conf %config(noreplace) %attr(0640,-,-) %{_sysconfdir}/%{name}/nodes.conf
%{_sysconfdir}/bash_completion.d/warewulf %{_sysconfdir}/bash_completion.d/warewulf
%dir %{wwshared}/%{name} %dir %{_localstatedir}/warewulf
%{wwshared}/%{name}/overlays/* %{_localstatedir}/warewulf/chroots
%{_localstatedir}/warewulf/overlays
%{srvdir}
%attr(-, root, root) %{_bindir}/wwctl %attr(-, root, root) %{_bindir}/wwctl
%attr(-, root, root) %{_prefix}/lib/firewalld/services/warewulf.xml %attr(-, root, root) %{_prefix}/lib/firewalld/services/warewulf.xml