Extend and optimize relocatable build config infrastructure
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -18,3 +18,8 @@
|
||||
/etc/bash_completion.d/
|
||||
/etc/warewulf.conf
|
||||
warewulf.spec
|
||||
internal/pkg/buildconfig/buildconfig.go
|
||||
include/systemd/warewulfd.service
|
||||
_dist/
|
||||
config
|
||||
warewulf-*.tar.gz
|
||||
|
||||
154
Makefile
154
Makefile
@@ -3,20 +3,35 @@
|
||||
VERSION ?= 4.2.0
|
||||
RELEASE ?= 1
|
||||
|
||||
SRC ?= main
|
||||
SRC ?= HEAD
|
||||
|
||||
VERSION_FULL ?= $(shell test -e .git && git describe --tags --long --first-parent --always)
|
||||
ifeq ($(VERSION_FULL),)
|
||||
VERSION_FULL := $(VERSION)
|
||||
endif
|
||||
|
||||
WWROOT ?= /var/lib
|
||||
# warewulf subdir automatcally added to TFTPROOT
|
||||
TFTPROOT ?= /var/lib/tftpboot
|
||||
# SUSE: TFTPROOT ?= /srv/tftpboot
|
||||
# Ubuntu: TFTPROOT ?= /srv/tftp
|
||||
FIREWALLDIR ?= /usr/lib/firewalld/services
|
||||
OVERLAYDIR ?= $(WWROOT)/warewulf/overlays
|
||||
# System locations
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
SYSCONFDIR ?= $(PREFIX)/etc
|
||||
SRVDIR ?= $(PREFIX)/srv
|
||||
SHAREDIR ?= $(PREFIX)/share
|
||||
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
|
||||
TOOLS_DIR := .tools
|
||||
@@ -64,8 +79,23 @@ $(TOOLS_DIR):
|
||||
|
||||
# Pre-build steps for source, such as "go generate"
|
||||
config:
|
||||
sed -e 's,@WWROOT@,$(WWROOT),g; s,@VERSION@,$(VERSION),g; s,@RELEASE@,$(RELEASE),g' warewulf.spec.in > warewulf.spec
|
||||
sed -e 's,@WWROOT@,$(WWROOT),g; s,@TFTPROOT@,$(TFTPROOT),g' etc/warewulf.conf.in > etc/warewulf.conf
|
||||
set -x ;\
|
||||
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: setup_tools config
|
||||
@@ -91,63 +121,60 @@ test-cover: ## Run test coverage and generate html report
|
||||
debian: all
|
||||
|
||||
files: all
|
||||
install -d -m 0755 $(DESTDIR)/usr/bin/
|
||||
install -d -m 0755 $(DESTDIR)$(WWROOT)/warewulf/
|
||||
install -d -m 0755 $(DESTDIR)$(WWROOT)/warewulf/chroots
|
||||
install -d -m 0755 $(DESTDIR)$(WWROOT)/warewulf/provision
|
||||
install -d -m 0755 $(DESTDIR)/etc/warewulf/
|
||||
install -d -m 0755 $(DESTDIR)/etc/warewulf/ipxe
|
||||
install -d -m 0755 $(DESTDIR)$(TFTPROOT)/warewulf/ipxe/
|
||||
install -d -m 0755 $(DESTDIR)/etc/bash_completion.d/
|
||||
install -d -m 0755 $(DESTDIR)/usr/share/man/man1
|
||||
test -f $(DESTDIR)/etc/warewulf/warewulf.conf || install -m 644 etc/warewulf.conf $(DESTDIR)/etc/warewulf/
|
||||
test -f $(DESTDIR)/etc/warewulf/hosts.tmpl || install -m 644 etc/hosts.tmpl $(DESTDIR)/etc/warewulf/
|
||||
test -f $(DESTDIR)/etc/warewulf/nodes.conf || install -m 644 etc/nodes.conf $(DESTDIR)/etc/warewulf/
|
||||
cp -r etc/dhcp $(DESTDIR)/etc/warewulf/
|
||||
cp -r etc/ipxe $(DESTDIR)/etc/warewulf/
|
||||
mkdir -p $(DESTDIR)$(OVERLAYDIR)
|
||||
cp -r overlays/* $(DESTDIR)$(OVERLAYDIR)/
|
||||
mkdir -p $(DESTDIR)$(OVERLAYDIR)/wwinit/bin/
|
||||
mkdir -p $(DESTDIR)$(OVERLAYDIR)/wwinit/warewulf/bin/
|
||||
chmod +x $(DESTDIR)$(OVERLAYDIR)/wwinit/init
|
||||
chmod 600 $(DESTDIR)$(OVERLAYDIR)/wwinit/etc/ssh/ssh*
|
||||
chmod 644 $(DESTDIR)$(OVERLAYDIR)/wwinit/etc/ssh/ssh*.pub.ww
|
||||
mkdir -p $(DESTDIR)$(OVERLAYDIR)/wwinit/warewulf/bin/
|
||||
install -m 0755 wwctl $(DESTDIR)/usr/bin/
|
||||
mkdir -p $(DESTDIR)$(FIREWALLDIR)
|
||||
install -c -m 0644 include/firewalld/warewulf.xml $(DESTDIR)$(FIREWALLDIR)
|
||||
mkdir -p $(DESTDIR)/usr/lib/systemd/system
|
||||
install -c -m 0644 include/systemd/warewulfd.service $(DESTDIR)/usr/lib/systemd/system
|
||||
cp bash_completion.d/warewulf $(DESTDIR)/etc/bash_completion.d/
|
||||
cp man_pages/* $(DESTDIR)/usr/share/man/man1/
|
||||
install -d -m 0755 $(DESTDIR)$(BINDIR)
|
||||
install -d -m 0755 $(DESTDIR)$(WWCHROOTDIR)
|
||||
install -d -m 0755 $(DESTDIR)$(WWPROVISIONDIR)
|
||||
install -d -m 0755 $(DESTDIR)$(WWOVERLAYDIR)
|
||||
install -d -m 0755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/bin/
|
||||
install -d -m 0755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/warewulf/bin/
|
||||
install -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/warewulf/
|
||||
install -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/warewulf/ipxe
|
||||
install -d -m 0755 $(DESTDIR)$(TFTPDIR)/warewulf/ipxe/
|
||||
install -d -m 0755 $(DESTDIR)$(BASH_COMPLETION)
|
||||
install -d -m 0755 $(DESTDIR)$(SHAREDIR)/man/man1
|
||||
install -d -m 0755 $(DESTDIR)$(FIREWALLDDIR)
|
||||
install -d -m 0755 $(DESTDIR)$(SYSTEMDDIR)
|
||||
test -f $(DESTDIR)$(SYSCONFDIR)/warewulf/warewulf.conf || install -m 644 etc/warewulf.conf $(DESTDIR)$(SYSCONFDIR)/warewulf/
|
||||
test -f $(DESTDIR)$(SYSCONFDIR)/warewulf/hosts.tmpl || install -m 644 etc/hosts.tmpl $(DESTDIR)$(SYSCONFDIR)/warewulf/
|
||||
test -f $(DESTDIR)$(SYSCONFDIR)/warewulf/nodes.conf || install -m 644 etc/nodes.conf $(DESTDIR)$(SYSCONFDIR)/warewulf/
|
||||
cp -r etc/dhcp $(DESTDIR)$(SYSCONFDIR)/warewulf/
|
||||
cp -r etc/ipxe $(DESTDIR)$(SYSCONFDIR)/warewulf/
|
||||
cp -r overlays/* $(DESTDIR)$(WWOVERLAYDIR)/
|
||||
chmod 755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/init
|
||||
chmod 600 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/ssh/ssh*
|
||||
chmod 644 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/ssh/ssh*.pub.ww
|
||||
install -m 0755 wwctl $(DESTDIR)$(BINDIR)
|
||||
install -c -m 0644 include/firewalld/warewulf.xml $(DESTDIR)$(FIREWALLDDIR)
|
||||
install -c -m 0644 include/systemd/warewulfd.service $(DESTDIR)$(SYSTEMDDIR)
|
||||
cp bash_completion.d/warewulf $(DESTDIR)$(BASH_COMPLETION)
|
||||
cp man_pages/* $(DESTDIR)$(MANDIR)/man1/
|
||||
|
||||
init:
|
||||
systemctl daemon-reload
|
||||
cp -r tftpboot/* $(TFTPROOT)/warewulf/ipxe/
|
||||
restorecon -r $(TFTPROOT)/warewulf
|
||||
cp -r tftpboot/* $(TFTPDIR)/warewulf/ipxe/
|
||||
restorecon -r $(TFTPDIR)/warewulf
|
||||
|
||||
debfiles: debian
|
||||
chmod +x $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/init
|
||||
chmod 600 $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/etc/ssh/ssh*
|
||||
chmod 644 $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/etc/ssh/ssh*.pub.ww
|
||||
mkdir -p $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/warewulf/bin/
|
||||
cp wwclient $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/warewulf/bin/
|
||||
# Overlay file system has changed
|
||||
#debfiles: debian
|
||||
# chmod +x $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/init
|
||||
# chmod 600 $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/etc/ssh/ssh*
|
||||
# chmod 644 $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/etc/ssh/ssh*.pub.ww
|
||||
# mkdir -p $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/warewulf/bin/
|
||||
# cp wwclient $(DESTDIR)$(WWROOT)/warewulf/overlays/system/debian/warewulf/bin/
|
||||
|
||||
wwctl:
|
||||
cd cmd/wwctl; GOOS=linux go build \
|
||||
-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
|
||||
cd cmd/wwctl; GOOS=linux go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../wwctl
|
||||
|
||||
wwclient:
|
||||
cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags '-extldflags -static' -o ../../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:
|
||||
cd cmd/bash_completion && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=$(CONFIG)/etc/warewulf.conf'\
|
||||
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=$(CONFIG)/etc/nodes.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=./etc/nodes.conf'"\
|
||||
-mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../bash_completion
|
||||
|
||||
bash_completion.d: bash_completion
|
||||
@@ -155,8 +182,8 @@ bash_completion.d: bash_completion
|
||||
./bash_completion bash_completion.d/warewulf
|
||||
|
||||
man_page:
|
||||
cd cmd/man_page && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=$(CONFIG)/etc/warewulf.conf'\
|
||||
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=$(CONFIG)/etc/nodes.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=./etc/nodes.conf'"\
|
||||
-mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../man_page
|
||||
|
||||
man_pages: man_page
|
||||
@@ -164,13 +191,13 @@ man_pages: man_page
|
||||
./man_page ./man_pages
|
||||
cd man_pages; for i in wwctl*1; do echo "Compressing manpage: $$i"; gzip --force $$i; done
|
||||
|
||||
config_defaults:
|
||||
cd cmd/config_defaults && go build -ldflags="-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.ConfigFile=$(CONFIG)/etc/warewulf.conf' \
|
||||
-X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=$(CONFIG)/etc/nodes.conf' \
|
||||
-X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.defaultDataStore=$(WWROOT)/warewulf'" \
|
||||
-mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../config_defaults
|
||||
#config_defaults:
|
||||
# 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=./etc/nodes.conf' \
|
||||
# -X 'github.com/hpcng/warewulf/internal/pkg/warewulfconf.defaultDataStore=$(WWROOT)/warewulf'" \
|
||||
# -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../config_defaults
|
||||
|
||||
dist: vendor
|
||||
dist: vendor config
|
||||
rm -rf _dist/warewulf-$(VERSION)
|
||||
mkdir -p _dist/warewulf-$(VERSION)
|
||||
git archive --format=tar $(SRC) | tar -xf - -C _dist/warewulf-$(VERSION)
|
||||
@@ -188,7 +215,8 @@ clean:
|
||||
rm -f man_page
|
||||
rm -rf man_pages
|
||||
rm -rf vendor
|
||||
rm -f config_defaults
|
||||
# rm -f config_defaults
|
||||
rm -f config
|
||||
|
||||
install: files install_wwclient
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ warewulf:
|
||||
autobuild overlays: true
|
||||
update interval: 60
|
||||
syslog: false
|
||||
datastore: @WWROOT@/warewulf
|
||||
datastore: @WWPROVISIONDIR@
|
||||
dhcp:
|
||||
enabled: true
|
||||
range start: 192.168.200.50
|
||||
@@ -15,7 +15,7 @@ dhcp:
|
||||
systemd name: dhcpd
|
||||
tftp:
|
||||
enabled: true
|
||||
tftproot: @TFTPROOT@
|
||||
tftproot: @TFTPDIR@
|
||||
systemd name: tftp
|
||||
nfs:
|
||||
systemd name: nfs-server
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
Description=Warewulf cluster management daemon
|
||||
Documentation=https://warewulf.hpcng.org/
|
||||
After=network-online.target
|
||||
AssertFileIsExecutable=/usr/bin/wwctl
|
||||
AssertFileIsExecutable=@BINDIR@/wwctl
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=root
|
||||
Group=root
|
||||
|
||||
ExecStart=/usr/bin/wwctl server start
|
||||
ExecStart=@BINDIR@/wwctl server start
|
||||
PIDFile=/var/run/warewulfd.pid
|
||||
Restart=always
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -84,12 +85,12 @@ func Configure(show bool) error {
|
||||
d.Nodes = append(d.Nodes, nodes...)
|
||||
|
||||
if controller.Dhcp.Template == "" {
|
||||
templateFile = "/etc/warewulf/dhcp/default-dhcpd.conf"
|
||||
templateFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/dhcp/default-dhcpd.conf")
|
||||
} else {
|
||||
if strings.HasPrefix(controller.Dhcp.Template, "/") {
|
||||
templateFile = controller.Dhcp.Template
|
||||
} 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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ package hosts
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"path"
|
||||
"text/template"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -26,7 +28,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
func Configure(show bool) error {
|
||||
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")
|
||||
return nil
|
||||
}
|
||||
@@ -43,7 +45,7 @@ func Configure(show bool) error {
|
||||
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 {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not parse hosts template: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -101,7 +101,7 @@ func Configure(show bool) error {
|
||||
fmt.Printf("%s %s/%s\n", export.Path, controller.Network, controller.Netmask)
|
||||
}
|
||||
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 {
|
||||
fmt.Printf("%s:%s %s nfs defaults 0 0\n", controller.Ipaddr, export, export)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/pkg/errors"
|
||||
@@ -19,15 +20,17 @@ func Configure(show bool) error {
|
||||
if os.Getuid() == 0 {
|
||||
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 {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not create base directory: %s\n", err)
|
||||
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")
|
||||
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 {
|
||||
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")
|
||||
}
|
||||
|
||||
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")
|
||||
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 {
|
||||
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")
|
||||
}
|
||||
|
||||
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")
|
||||
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 {
|
||||
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")
|
||||
}
|
||||
|
||||
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")
|
||||
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 {
|
||||
return errors.Wrap(err, "failed to exec ssh-keygen command")
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/staticfiles"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -23,40 +24,35 @@ func Configure(show bool) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Tftp.TftpRoot == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Tftp root directory is not configured in warewulfd.conf\n")
|
||||
if buildconfig.TFTPDIR == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Tftp root directory is not configured by build\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !util.IsDir(controller.Tftp.TftpRoot) {
|
||||
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)
|
||||
err = os.MkdirAll(path.Join(buildconfig.TFTPDIR, "warewulf"), 0755)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !show {
|
||||
fmt.Printf("Writing PXE files to: %s\n", path.Join(controller.Tftp.TftpRoot, "warewulf"))
|
||||
err = staticfiles.WriteData("files/tftp/x86.efi", path.Join(controller.Tftp.TftpRoot, "warewulf/x86.efi"))
|
||||
fmt.Printf("Writing PXE files to: %s\n", path.Join(buildconfig.TFTPDIR, "warewulf"))
|
||||
err = staticfiles.WriteData("files/tftp/x86.efi", path.Join(buildconfig.TFTPDIR, "warewulf/x86.efi"))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
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 {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
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 {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
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 {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"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/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/set"
|
||||
nodestatus "github.com/hpcng/warewulf/internal/app/wwctl/node/status"
|
||||
@@ -30,7 +29,6 @@ func init() {
|
||||
baseCmd.AddCommand(add.GetCommand())
|
||||
baseCmd.AddCommand(delete.GetCommand())
|
||||
baseCmd.AddCommand(console.GetCommand())
|
||||
baseCmd.AddCommand(ready.GetCommand())
|
||||
baseCmd.AddCommand(nodestatus.GetCommand())
|
||||
}
|
||||
|
||||
|
||||
16
internal/pkg/buildconfig/buildconfig.go.in
Normal file
16
internal/pkg/buildconfig/buildconfig.go.in
Normal 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@"
|
||||
)
|
||||
27
internal/pkg/container/config.go
Normal file
27
internal/pkg/container/config.go
Normal 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")
|
||||
}
|
||||
@@ -3,11 +3,9 @@ package container
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
@@ -20,26 +18,6 @@ func ValidName(name string) bool {
|
||||
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) {
|
||||
var ret []string
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"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/wwlog"
|
||||
)
|
||||
@@ -26,8 +26,8 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func ParentDir() string {
|
||||
return path.Join(warewulfconf.DataStore(), "provision/kernel")
|
||||
func KernelImageTopDir() string {
|
||||
return path.Join(buildconfig.WWPROVISIONDIR, "kernel")
|
||||
}
|
||||
|
||||
func KernelImage(kernelName string) string {
|
||||
@@ -41,7 +41,7 @@ func KernelImage(kernelName string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(ParentDir(), kernelName, "vmlinuz")
|
||||
return path.Join(KernelImageTopDir(), kernelName, "vmlinuz")
|
||||
}
|
||||
|
||||
func GetKernelVersion(kernelName string) string {
|
||||
@@ -49,7 +49,7 @@ func GetKernelVersion(kernelName string) string {
|
||||
wwlog.Printf(wwlog.ERROR, "Kernel Name is not defined\n")
|
||||
return ""
|
||||
}
|
||||
kernelVersion, err := ioutil.ReadFile(path.Join(ParentDir(), kernelName, "version"))
|
||||
kernelVersion, err := ioutil.ReadFile(KernelVersionFile(kernelName))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
@@ -67,10 +67,10 @@ func KmodsImage(kernelName string) string {
|
||||
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 == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Kernel Name is not defined\n")
|
||||
return ""
|
||||
@@ -81,20 +81,20 @@ func KernelVersion(kernelName string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(ParentDir(), kernelName, "version")
|
||||
return path.Join(KernelImageTopDir(), kernelName, "version")
|
||||
}
|
||||
|
||||
func ListKernels() ([]string, error) {
|
||||
var ret []string
|
||||
|
||||
err := os.MkdirAll(ParentDir(), 0755)
|
||||
err := os.MkdirAll(KernelImageTopDir(), 0755)
|
||||
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 {
|
||||
return ret, err
|
||||
}
|
||||
@@ -109,12 +109,12 @@ func ListKernels() ([]string, error) {
|
||||
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)
|
||||
kernelDriversRelative := path.Join("/lib/modules/"+kernelVersion)
|
||||
kernelDriversRelative := path.Join("/lib/modules/" + kernelVersion)
|
||||
kernelDestination := KernelImage(kernelName)
|
||||
driversDestination := KmodsImage(kernelName)
|
||||
versionDestination := KernelVersion(kernelName)
|
||||
versionDestination := KernelVersionFile(kernelName)
|
||||
var kernelSource string
|
||||
|
||||
// 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 {
|
||||
fullPath := path.Join(ParentDir(), name)
|
||||
fullPath := path.Join(KernelImageTopDir(), name)
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Removing path: %s\n", fullPath)
|
||||
return os.RemoveAll(fullPath)
|
||||
|
||||
@@ -3,14 +3,23 @@ package node
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
|
||||
"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) {
|
||||
var ret nodeYaml
|
||||
|
||||
@@ -3,13 +3,11 @@ package overlay
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
)
|
||||
|
||||
func OverlaySourceTopDir() string {
|
||||
return path.Join(warewulfconf.DataStore(), "overlays/")
|
||||
return buildconfig.WWOVERLAYDIR
|
||||
}
|
||||
|
||||
func OverlaySourceDir(overlayName string) string {
|
||||
@@ -17,68 +15,5 @@ func OverlaySourceDir(overlayName string) string {
|
||||
}
|
||||
|
||||
func OverlayImage(nodeName string, overlayName string) string {
|
||||
return path.Join(warewulfconf.DataStore(), "/provision/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")
|
||||
return path.Join(buildconfig.WWPROVISIONDIR, "overlays/", nodeName, overlayName+".img")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package version
|
||||
|
||||
var Version string = "development"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
)
|
||||
|
||||
func GetVersion() string {
|
||||
return Version
|
||||
return fmt.Sprintf("%s-%s", buildconfig.VERSION, buildconfig.RELEASE)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package warewulfconf
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"errors"
|
||||
"path"
|
||||
|
||||
"github.com/brotherpowers/ipsubnet"
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
@@ -14,6 +16,14 @@ import (
|
||||
|
||||
var cachedConf ControllerConf
|
||||
|
||||
var ConfigFile string
|
||||
|
||||
func init() {
|
||||
if ConfigFile == "" {
|
||||
ConfigFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/warewulf.conf")
|
||||
}
|
||||
}
|
||||
|
||||
func New() (ControllerConf, error) {
|
||||
var ret ControllerConf = *defaultConfig()
|
||||
|
||||
@@ -32,8 +42,8 @@ func New() (ControllerConf, error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// TODO: Need to add comprehensive config file validator
|
||||
// TODO: Change function to guess default IP address and/or mask from local system
|
||||
// TODO: Need to add comprehensive config file validator
|
||||
// TODO: Change function to guess default IP address and/or mask from local system
|
||||
if ret.Ipaddr == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "IP address is not configured in warewulfd.conf\n")
|
||||
return ret, errors.New("no IP Address")
|
||||
@@ -63,7 +73,7 @@ func New() (ControllerConf, error) {
|
||||
|
||||
} else {
|
||||
wwlog.Printf(wwlog.DEBUG, "Returning cached warewulf config object\n")
|
||||
// If cached struct isn't empty, use it as the return value
|
||||
// If cached struct isn't empty, use it as the return value
|
||||
ret = cachedConf
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package warewulfconf
|
||||
|
||||
const defaultPort int = 9983
|
||||
const defaultPort int = 9983
|
||||
|
||||
var (
|
||||
ConfigFile string = "/etc/warewulf/warewulf.conf"
|
||||
defaultDataStore string = "/var/lib/warewulf"
|
||||
)
|
||||
var defaultDataStore string = "/var/lib/warewulf"
|
||||
|
||||
func defaultConfig() *ControllerConf {
|
||||
Warewulf := &WarewulfConf{
|
||||
@@ -30,8 +27,8 @@ func defaultConfig() *ControllerConf {
|
||||
SystemdName: "tftp",
|
||||
}
|
||||
Nfs := &NfsConf{
|
||||
Enabled: true,
|
||||
Exports: []string{"/home",},
|
||||
Enabled: true,
|
||||
Exports: []string{"/home"},
|
||||
SystemdName: "nfs-server",
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package warewulfd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -100,7 +101,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
if unconfiguredNode {
|
||||
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 {
|
||||
daemonLogf("ERROR: Could not parse unconfigured node IPXE template: %s\n", err)
|
||||
return
|
||||
@@ -120,7 +121,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
} 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)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
%global wwgroup warewulf
|
||||
%global wwshared @WWROOT@
|
||||
%if 0%{?sle_version}
|
||||
%global tftpdir "/srv/tftpboot"
|
||||
%global srvdir "/srv"
|
||||
%else
|
||||
%global tftpdir "/var/lib/tftpboot"
|
||||
%global srvdir "%{_localstatedir}/warewulf/srv"
|
||||
%endif
|
||||
%define debug_package %{nil}
|
||||
|
||||
@@ -13,7 +14,7 @@ Version: @VERSION@
|
||||
Release: @RELEASE@%{?dist}
|
||||
License: BSD-3-Clause
|
||||
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
|
||||
|
||||
@@ -56,11 +57,30 @@ system for large clusters of bare metal and/or virtual systems.
|
||||
|
||||
|
||||
%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
|
||||
%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
|
||||
@@ -86,8 +106,10 @@ getent group %{wwgroup} >/dev/null || groupadd -r %{wwgroup}
|
||||
%config(noreplace) %attr(0640,-,-) %{_sysconfdir}/%{name}/nodes.conf
|
||||
%{_sysconfdir}/bash_completion.d/warewulf
|
||||
|
||||
%dir %{wwshared}/%{name}
|
||||
%{wwshared}/%{name}/overlays/*
|
||||
%dir %{_localstatedir}/warewulf
|
||||
%{_localstatedir}/warewulf/chroots
|
||||
%{_localstatedir}/warewulf/overlays
|
||||
%{srvdir}
|
||||
|
||||
%attr(-, root, root) %{_bindir}/wwctl
|
||||
%attr(-, root, root) %{_prefix}/lib/firewalld/services/warewulf.xml
|
||||
|
||||
Reference in New Issue
Block a user