Rollcall: bare-metal commissioning server, agent, image build, lab and CI
Go server (API, embedded web UI, CLI) backed by PostgreSQL with AES-GCM sealed BMC secrets; Debian live commissioning agent and live-build recipe; Proxmox lab with pve-vbmc virtual BMCs; Gitea workflows for CI, releases and deployment; project website. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
commit
d9ae89b295
33 files changed
+3248
No files matched your search
@@ -0,0 +1,79 @@
|
||||
# Runs on the containerized act_runner (label: ubuntu-latest).
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
go:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: cmd/rollcall/go.mod
|
||||
cache-dependency-path: cmd/rollcall/go.sum
|
||||
cache: true
|
||||
|
||||
- name: gofmt
|
||||
working-directory: cmd/rollcall
|
||||
run: |
|
||||
out=$(gofmt -l .)
|
||||
if [ -n "$out" ]; then echo "gofmt needed on:"; echo "$out"; exit 1; fi
|
||||
|
||||
- name: go vet
|
||||
working-directory: cmd/rollcall
|
||||
run: go vet ./...
|
||||
|
||||
- name: go test
|
||||
working-directory: cmd/rollcall
|
||||
run: go test -race -timeout 5m ./...
|
||||
|
||||
- name: Build (static, linux/amd64 and linux/arm64)
|
||||
working-directory: cmd/rollcall
|
||||
run: |
|
||||
for arch in amd64 arm64; do
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -trimpath -ldflags="-s -w" -o rollcall-linux-$arch .
|
||||
done
|
||||
ls -la rollcall-linux-*
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: rollcall-linux-amd64
|
||||
path: cmd/rollcall/rollcall-linux-amd64
|
||||
|
||||
agent:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Python syntax + shell syntax
|
||||
run: |
|
||||
python3 -m py_compile agent/rollcall-agent.py lab/pve-vbmc/pve_vbmc.py
|
||||
for f in agent/build-image.sh deploy/install.sh lab/pve-vbmc/install.sh lab/pve-vbmc/pve-vbmc-addrs.sh; do
|
||||
bash -n "$f" || sh -n "$f"
|
||||
done
|
||||
- name: Config examples are valid JSON
|
||||
run: |
|
||||
python3 -c 'import json,sys; [json.load(open(f)) for f in sys.argv[1:]]' deploy/config.example.json lab/pve-vbmc/config.example.json
|
||||
- name: No secrets committed
|
||||
run: |
|
||||
# the agent token must stay a placeholder in the tracked PXE menu
|
||||
grep -q '@AGENT_TOKEN@' deploy/pxelinux-default
|
||||
! grep -rEn 'rollcall\.token=[0-9a-f]{16,}' --exclude-dir=.git . || { echo "real agent token committed"; exit 1; }
|
||||
|
||||
site:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: HTML sanity
|
||||
run: |
|
||||
test -f site/index.html
|
||||
python3 - <<'EOF'
|
||||
from html.parser import HTMLParser
|
||||
class P(HTMLParser):
|
||||
def __init__(self): super().__init__(); self.depth=0
|
||||
p=P(); p.feed(open('site/index.html').read()); print("ok")
|
||||
EOF
|
||||
@@ -0,0 +1,101 @@
|
||||
# Continuous deployment to the lab PXE server after CI passes on main.
|
||||
#
|
||||
# Secrets: PXE_SSH_KEY private key for the deploy user on the PXE server
|
||||
# Variables: PXE_HOST e.g. 10.0.0.234 PXE_USER e.g. ilker (needs passwordless sudo)
|
||||
# SITE_HOST / SITE_USER / SITE_PATH optional: rsync target for the website
|
||||
#
|
||||
# The image rebuild (agent/**) runs live-build on the PXE server itself (~8 min)
|
||||
# and only when agent files changed, or when dispatched by hand.
|
||||
name: deploy
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [CI]
|
||||
types: [completed]
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
rebuild_image:
|
||||
description: 'Rebuild the commissioning image too'
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: deploy
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
server:
|
||||
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: cmd/rollcall/go.mod
|
||||
cache-dependency-path: cmd/rollcall/go.sum
|
||||
|
||||
- name: Build
|
||||
working-directory: cmd/rollcall
|
||||
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o ../../deploy/rollcall .
|
||||
|
||||
- name: SSH setup
|
||||
env:
|
||||
KEY: ${{ secrets.PXE_SSH_KEY }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||
printf '%s\n' "$KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
|
||||
printf 'Host *\n StrictHostKeyChecking accept-new\n' > ~/.ssh/config
|
||||
|
||||
- name: Ship binary + deploy files and restart
|
||||
env:
|
||||
HOST: ${{ vars.PXE_HOST }}
|
||||
USER: ${{ vars.PXE_USER }}
|
||||
run: |
|
||||
set -eu
|
||||
ssh "$USER@$HOST" 'sudo mkdir -p /opt/rollcall/deploy /opt/rollcall/agent && sudo chown -R "$USER" /opt/rollcall'
|
||||
scp -q deploy/rollcall deploy/install.sh deploy/rollcall.service deploy/pxelinux-default deploy/config.example.json "$USER@$HOST:/opt/rollcall/deploy/"
|
||||
scp -q agent/rollcall-agent.py agent/rollcall-agent.service agent/build-image.sh "$USER@$HOST:/opt/rollcall/agent/"
|
||||
ssh "$USER@$HOST" 'cd /opt/rollcall/deploy && chmod +x install.sh rollcall ../agent/*.sh ../agent/*.py && sudo ./install.sh && sudo rollcall list >/dev/null && echo DEPLOY_OK'
|
||||
|
||||
image:
|
||||
needs: server
|
||||
if: >
|
||||
(github.event_name == 'workflow_dispatch' && inputs.rebuild_image) ||
|
||||
(github.event_name == 'workflow_run' && contains(join(github.event.workflow_run.head_commit.message, ' '), '[image]'))
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: SSH setup
|
||||
env:
|
||||
KEY: ${{ secrets.PXE_SSH_KEY }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||
printf '%s\n' "$KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
|
||||
printf 'Host *\n StrictHostKeyChecking accept-new\n ServerAliveInterval 30\n' > ~/.ssh/config
|
||||
- name: Rebuild the live image on the PXE server
|
||||
env:
|
||||
HOST: ${{ vars.PXE_HOST }}
|
||||
USER: ${{ vars.PXE_USER }}
|
||||
run: ssh "$USER@$HOST" 'sudo /opt/rollcall/agent/build-image.sh 2>&1 | tail -20'
|
||||
|
||||
site:
|
||||
needs: server
|
||||
if: vars.SITE_HOST != ''
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: SSH setup
|
||||
env:
|
||||
KEY: ${{ secrets.SITE_SSH_KEY || secrets.PXE_SSH_KEY }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||
printf '%s\n' "$KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
|
||||
printf 'Host *\n StrictHostKeyChecking accept-new\n' > ~/.ssh/config
|
||||
- name: Publish website
|
||||
env:
|
||||
HOST: ${{ vars.SITE_HOST }}
|
||||
USER: ${{ vars.SITE_USER }}
|
||||
DEST: ${{ vars.SITE_PATH }}
|
||||
run: |
|
||||
set -eu
|
||||
tar -C site -czf - . | ssh "$USER@$HOST" "mkdir -p '$DEST' && tar -C '$DEST' -xzf - && echo SITE_OK"
|
||||
@@ -0,0 +1,43 @@
|
||||
# Tag v* -> build static binaries and publish them as a Gitea release.
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: cmd/rollcall/go.mod
|
||||
cache-dependency-path: cmd/rollcall/go.sum
|
||||
|
||||
- name: Build
|
||||
working-directory: cmd/rollcall
|
||||
run: |
|
||||
set -eu
|
||||
for arch in amd64 arm64; do
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -trimpath \
|
||||
-ldflags="-s -w -X main.version=${GITHUB_REF_NAME}" -o rollcall-linux-$arch .
|
||||
done
|
||||
sha256sum rollcall-linux-* > SHA256SUMS
|
||||
|
||||
- name: Create release and upload assets
|
||||
env:
|
||||
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
working-directory: cmd/rollcall
|
||||
run: |
|
||||
set -eu
|
||||
body=$(printf '{"tag_name":"%s","name":"%s","draft":false,"prerelease":false}' "$TAG" "$TAG")
|
||||
id=$(curl -sfS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d "$body" "$API/releases" | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')
|
||||
for f in rollcall-linux-amd64 rollcall-linux-arm64 SHA256SUMS; do
|
||||
curl -sfS -X POST -H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$f" "$API/releases/$id/assets?name=$f" >/dev/null
|
||||
echo "uploaded $f"
|
||||
done
|
||||
Reference in new issue
Block a user