An installation used to be this one: the deploy scripts and the Ansible defaults carried one site's domain, hypervisor and login, the Proxmox side and the database were set up by hand, and deploying meant copying scripts and a tree of roles beside the binary and keeping them in step with it. The binary now carries the roles, the Terraform module, the schema and the catalogue (embed.go), and installs itself: - hpcod setup: a full-screen installer for administrators. It asks where clusters are built, signs in to Proxmox before asking anything else (root's password once, or tokens), offers nodes and datastores from what Proxmox has, checks every field as it is typed, runs every step with its output live, checks the result and offers a test cluster. -yes runs the same steps from a site file; make deploy uses that. - hpcod verify: each fact checked by using it. - hpcod selftest: the smallest real cluster, by the portal's own path, a job run on it, then taken down. - Closed networks: hpcod serves HTTPS itself from a CA name-constrained to the site's domains, issuing and renewing its own certificate, and answers DNS for the portal and every cluster name. - A simulated Proxmox: Proxmox VE in QEMU on the control plane host, on a private bridge with NAT, for trying it without one. Every step reads back what it changed and is safe to run again. The site's values live in one file; group_vars/all/site.yml is generated from it, and the playbooks refuse to run without it. ci_user and -ssh-user no longer default to a personal account. scripts/B10, B20 and C20 are gone: their work is the setup steps. Proven end to end on a simulated Proxmox (Proxmox VE 9 in a VM on a real host): the install, the Proxmox step by the password path, the head template, verify READY, and a test cluster that ran srun on its compute node and was destroyed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94 lines
3.9 KiB
Makefile
94 lines
3.9 KiB
Makefile
BIN := hpcod
|
|
|
|
# The release tag, for `hpcod version`. Deliberately without --always: with no
|
|
# tag in sight this is empty, and the binary reports its revision alone rather
|
|
# than a made-up version. --dirty is what stops a local edit from claiming to
|
|
# be the release.
|
|
VERSION := $(shell git describe --tags --dirty 2>/dev/null)
|
|
LDFLAGS := -s -w -X main.releaseVersion=$(VERSION)
|
|
|
|
# Where the release artefacts land, and which machines they are for: the
|
|
# control plane runs on Linux, the CLI is driven from whatever the operator
|
|
# sits in front of.
|
|
DIST := dist
|
|
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
|
|
|
|
# Where it goes. Everything about the installation - this included - is in
|
|
# one file, so that someone else's deploy is their file and this Makefile.
|
|
SITE_ENV ?= deploy/site.env
|
|
DEPLOY_HOST ?= $(shell sed -n 's/^DEPLOY_HOST=//p' $(SITE_ENV) 2>/dev/null | tr -d '"')
|
|
|
|
.PHONY: all linux test clean site deploy deploy-portal verify selftest release
|
|
all: linux
|
|
|
|
# The control plane host's architecture: LINUX_ARCH=arm64 for an arm64 host.
|
|
LINUX_ARCH ?= amd64
|
|
LINUX_BIN := $(BIN)-linux-$(LINUX_ARCH)
|
|
|
|
linux:
|
|
GOOS=linux GOARCH=$(LINUX_ARCH) CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o $(LINUX_BIN) ./cmd/hpcod
|
|
@ls -lh $(LINUX_BIN)
|
|
|
|
test:
|
|
go vet ./... && go test ./...
|
|
|
|
site:
|
|
@[ -f $(SITE_ENV) ] || { echo "no $(SITE_ENV): cp deploy/site.env.example $(SITE_ENV), then fill it in (DEPLOY.md)"; exit 1; }
|
|
@[ -n "$(DEPLOY_HOST)" ] || { echo "$(SITE_ENV) does not set DEPLOY_HOST"; exit 1; }
|
|
|
|
# Ship one binary and the site file, and let it install itself. The binary
|
|
# carries the roles, the Terraform module, the schema and the catalogue, so
|
|
# there is nothing else to send and nothing on the host to fall out of step
|
|
# with it. Setup is idempotent: on a host that already runs the portal it
|
|
# rewrites only what it generates, applies the schema, and restarts last.
|
|
#
|
|
# The template step only builds a template that is missing; pass
|
|
# SETUP_ARGS=-rebuild-template after the roles change. Proxmox credentials,
|
|
# needed only on a first install, come from the environment on the host
|
|
# (see `hpcod setup -h`); without them the Proxmox step reports what it
|
|
# needs - or run `sudo hpcod setup` there for the interactive installer.
|
|
SETUP_ARGS ?=
|
|
deploy: site linux
|
|
scp -q $(LINUX_BIN) $(DEPLOY_HOST):/tmp/hpcod
|
|
scp -q $(SITE_ENV) $(DEPLOY_HOST):/tmp/hpcod-site.env
|
|
ssh -t $(DEPLOY_HOST) 'sudo /tmp/hpcod setup -yes -config /tmp/hpcod-site.env $(SETUP_ARGS); rc=$$?; rm -f /tmp/hpcod /tmp/hpcod-site.env; exit $$rc'
|
|
|
|
# The binary alone, for a change that touches nothing else.
|
|
deploy-portal: site linux
|
|
scp -q $(LINUX_BIN) $(DEPLOY_HOST):/tmp/hpcod
|
|
ssh -t $(DEPLOY_HOST) 'sudo /tmp/hpcod setup -yes -only binary,start; rc=$$?; rm -f /tmp/hpcod; exit $$rc'
|
|
|
|
# Can this installation build a cluster? Checked on the host.
|
|
verify: site
|
|
ssh -t $(DEPLOY_HOST) 'sudo hpcod verify'
|
|
|
|
# Build a real cluster the way the portal does, run a job on it, remove it.
|
|
selftest: site
|
|
ssh -t $(DEPLOY_HOST) 'sudo hpcod selftest $(SELFTEST_ARGS)'
|
|
|
|
# Build every platform from one tag, and record what was built.
|
|
#
|
|
# It refuses to run from an untagged or edited tree. A release artefact whose
|
|
# version is a bare revision, or carries +dirty, is not a release - and the
|
|
# time to find that out is before it is uploaded, not when someone asks which
|
|
# binary is on a host.
|
|
release:
|
|
@case "$(VERSION)" in \
|
|
"") echo "no tag here: git tag -a vX.Y.Z first"; exit 1 ;; \
|
|
*dirty) echo "working tree is dirty: $(VERSION)"; exit 1 ;; \
|
|
*-*-g*) echo "not on a tag: $(VERSION)"; exit 1 ;; \
|
|
esac
|
|
rm -rf $(DIST) && mkdir -p $(DIST)
|
|
@for p in $(PLATFORMS); do \
|
|
os=$${p%/*}; arch=$${p#*/}; out=$(DIST)/$(BIN)-$(VERSION)-$$os-$$arch; \
|
|
echo " $$out"; \
|
|
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 \
|
|
go build -trimpath -ldflags="$(LDFLAGS)" -o $$out ./cmd/hpcod || exit 1; \
|
|
done
|
|
cd $(DIST) && shasum -a 256 * > SHA256SUMS
|
|
@echo && cat $(DIST)/SHA256SUMS
|
|
|
|
clean:
|
|
rm -f $(BIN)-linux-*
|
|
rm -rf $(DIST)
|