Files
werewulf/hpcod/Makefile
T
ilkerandClaude Opus 5 04791c159e hpcod: deploy the tree the portal builds clusters with, in one step
`make deploy-portal` ships the binary, which is the smaller half. A
cluster is built by the Terraform module and configured by the
Ansible roles, and those live on the control plane as their own
copies. Copying them by hand, a file at a time, is how they came to
disagree - twice in one evening.

First the roles on the host had the single sign-on work and the copy
baked into the head template did not, so the first cluster the portal
built came up with no mTLS and answered its own tenant with 401. Then
the environment template was updated to pass control_plane_cert while
the module that receives it was not, and the next build died at plan
with "An argument named control_plane_cert is not expected here".

`make deploy-tree` sends the three together, and `make deploy` does
that and the binary. It leaves site.auto.tfvars alone - that is the
site's own, and it holds the Proxmox token - and never touches
terraform/envs, which is one working directory per cluster holding
its state.

It reads back what landed: the files hashed on the host and compared
here, not "scp exited 0". That caught its own first run - macOS tar
writes an AppleDouble twin beside every file with an extended
attribute, and GNU tar unpacked 37 of them as real files.

And the drift itself is now visible. The deploy stamps a REVISION
into the roles, which rides into the head template with them, so
/opt/hpcod/ansible/REVISION on any head says what configured it. B20
records what it baked, and the deploy compares: the repository being
current, and the control plane's copy being current, said nothing
about what clusters are actually built from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 07:28:52 +02:00

68 lines
2.6 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
.PHONY: all linux test clean deploy-portal deploy-tree deploy release
all: linux
linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o $(BIN)-linux-amd64 ./cmd/hpcod
@ls -lh $(BIN)-linux-amd64
test:
go vet ./... && go test ./...
# The portal runs on the Caddy host: it needs to reach every Proxmox API, and
# binding to loopback there means Caddy is the only thing that can reach it.
deploy-portal: linux
scp -q $(BIN)-linux-amd64 web-frontend:/tmp/hpcod
ssh web-frontend 'sudo install -m 0755 /tmp/hpcod /usr/local/bin/hpcod && sudo systemctl restart hpcod-portal && systemctl is-active hpcod-portal'
# 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
# The other half of a deploy: the Ansible roles and the Terraform module
# the portal builds clusters with. They live on the host as their own
# copies, and shipping the binary alone leaves them behind - which is how
# a cluster came to be built from month-old roles while the repository,
# and the binary, were current.
deploy-tree:
../scripts/C20-deploy-tree.sh
# What "deploy" should have meant all along.
deploy: deploy-portal deploy-tree
clean:
rm -f $(BIN)-linux-amd64
rm -rf $(DIST)