Install guide, release bundles, publishable commissioning image
INSTALL.md follows a clean run from day 0 to a deployed machine. Release assets now include rollcall-<tag>-linux-<arch>.tar.gz (binary, deploy/, agent/). deploy/publish-image.sh uploads a region's commissioning image to a release (commissioning-*); bootstrap.sh downloads either layout, with IMAGE_TOKEN for private repositories. bootstrap: --ssh-key (default: the operator's keys), keeps server_url on reruns without --iface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ff96d7e74
commit
623e7c0cc4
5 files changed
+244
-9
No files matched your search
+53
-7
@@ -17,19 +17,23 @@
|
||||
# or import the prefixes from NetBox (rollcall ipam import).
|
||||
#
|
||||
# --name NAME rack controller name of this host (default: short hostname)
|
||||
# --image-url directory with vmlinuz, initrd.img, filesystem.squashfs, SHA256SUMS
|
||||
# --image-url directory with vmlinuz, initrd.img, filesystem.squashfs, SHA256SUMS - a
|
||||
# region's http://HOST/rollcall, or a release's download URL, where the files are
|
||||
# commissioning-* (deploy/publish-image.sh); IMAGE_TOKEN=... for a private repository
|
||||
# --build-image build the commissioning image here with live-build (~20 min)
|
||||
# --gateway IP default router for machines on the provisioning network
|
||||
# --nat UPLINK this host routes for them: forward + masquerade out of UPLINK
|
||||
# (default with --iface and no --gateway: the default route's interface)
|
||||
# --domain D DNS domain handed to machines (default rollcall.internal)
|
||||
# --no-dhcp model the network but leave DHCP to the existing server
|
||||
# --ssh-key K SSH public key (or a file of them) for root on deployed machines; repeatable.
|
||||
# Default: the keys of the user running sudo, then root's.
|
||||
# --os NAME import one OS image now (e.g. debian-13); a nightly timer syncs the catalog
|
||||
# --yes do not ask
|
||||
set -euo pipefail
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
ROOT=$(cd "$HERE/.." && pwd)
|
||||
IFACE="" RACK=$(hostname -s) DOMAIN=rollcall.internal GATEWAY="" NAT="" IMAGE_URL="" BUILD=0 OS="" DHCP=1 YES=0
|
||||
IFACE="" RACK=$(hostname -s) DOMAIN=rollcall.internal GATEWAY="" NAT="" IMAGE_URL="" BUILD=0 OS="" DHCP=1 YES=0 SSHKEYS=()
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--iface) IFACE=$2; shift ;;
|
||||
@@ -40,6 +44,7 @@ while [ $# -gt 0 ]; do
|
||||
--image-url) IMAGE_URL=${2%/}; shift ;;
|
||||
--build-image) BUILD=1 ;;
|
||||
--os) OS=$2; shift ;;
|
||||
--ssh-key) SSHKEYS+=("$2"); shift ;;
|
||||
--no-dhcp) DHCP=0 ;;
|
||||
--yes|-y) YES=1 ;;
|
||||
-h|--help) sed -n '2,31p' "$0"; exit 0 ;;
|
||||
@@ -71,7 +76,11 @@ if [ -n "$IFACE" ]; then
|
||||
else
|
||||
[ -n "$UPLINK" ] || die "no default route: give this host network access first"
|
||||
ADDR=$(addr_of "$UPLINK" | cut -d/ -f1)
|
||||
echo " no provisioning network yet: the region starts on $UPLINK ($ADDR) without DHCP or subnets"
|
||||
if [ -f "$CONF" ]; then
|
||||
echo " existing installation: server address and network model are kept"
|
||||
else
|
||||
echo " no provisioning network yet: the region starts on $UPLINK ($ADDR) without DHCP or subnets"
|
||||
fi
|
||||
fi
|
||||
SERVER=http://$ADDR
|
||||
echo " region $SERVER, rack controller \"$RACK\""
|
||||
@@ -160,7 +169,8 @@ P
|
||||
ok "$CONF written (tokens generated; the web UI is HTTPS-only: admin_http loopback)"
|
||||
else
|
||||
# an existing installation: the provisioning address may have arrived since
|
||||
if python3 - "$CONF" "$SERVER" "$ADDR" "$FQDN" <<'P'
|
||||
# (without --iface the server address stays what it is)
|
||||
if [ -n "$IFACE" ] && python3 - "$CONF" "$SERVER" "$ADDR" "$FQDN" <<'P'
|
||||
import json, sys
|
||||
p, srv, addr, fqdn = sys.argv[1:]
|
||||
c = json.load(open(p))
|
||||
@@ -177,10 +187,41 @@ if changed:
|
||||
sys.exit(0 if changed else 1)
|
||||
P
|
||||
then CHANGED=1; ok "server_url now $SERVER (was different), tls_names updated"
|
||||
else ok "$CONF kept"
|
||||
else SERVER=$(jq -r .server_url "$CONF"); ok "$CONF kept (server $SERVER)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# SSH keys for deployed machines: given ones, else the operator's
|
||||
keyfiles=()
|
||||
if [ ${#SSHKEYS[@]} -eq 0 ] && grep -q '"ssh_keys": \[\]' "$CONF" 2>/dev/null; then
|
||||
for f in "/home/${SUDO_USER:-none}/.ssh/authorized_keys" /root/.ssh/authorized_keys; do [ -r "$f" ] && keyfiles+=("$f"); done
|
||||
fi
|
||||
if [ ${#SSHKEYS[@]} -gt 0 ] || [ ${#keyfiles[@]} -gt 0 ]; then
|
||||
n=$(python3 - "$CONF" "${SSHKEYS[@]}" -- "${keyfiles[@]}" <<'P2'
|
||||
import json, os, re, sys
|
||||
conf = sys.argv[1]; rest = sys.argv[2:]; sep = rest.index("--")
|
||||
given, files = rest[:sep], rest[sep + 1:]
|
||||
keyre = re.compile(r'((?:ssh-(?:ed25519|rsa|dss)|ecdsa-sha2-\S+|sk-\S+)\s+[A-Za-z0-9+/=]+(?:\s+\S+)?)')
|
||||
def keys_of(text):
|
||||
return [m.group(1).strip() for line in text.splitlines() for m in [keyre.search(line)] if m]
|
||||
found = []
|
||||
for g in given:
|
||||
found += keys_of(open(g).read()) if os.path.isfile(g) else keys_of(g)
|
||||
for f in files:
|
||||
found += keys_of(open(f).read())
|
||||
c = json.load(open(conf)); cv = c.setdefault("cluster_vars", {})
|
||||
have = cv.get("ssh_keys") or []
|
||||
new = [k for k in dict.fromkeys(found) if k not in have]
|
||||
if new:
|
||||
cv["ssh_keys"] = have + new
|
||||
json.dump(c, open(conf, "w"), indent=2)
|
||||
print(len(new))
|
||||
P2
|
||||
)
|
||||
[ "$n" -gt 0 ] && { ok "$n SSH key(s) for root on deployed machines"; CHANGED=1; } || true
|
||||
fi
|
||||
[ "$(jq '.cluster_vars.ssh_keys | length' "$CONF")" -gt 0 ] || echo " note: no SSH keys for deployed machines yet (--ssh-key KEY)" >&2
|
||||
|
||||
# ------------------------------------------------------------------ 6. services
|
||||
say "6/9 services"
|
||||
install -d /srv/rollcall/image
|
||||
@@ -196,8 +237,13 @@ if [ -s $IMG/vmlinuz ] && [ -s $IMG/initrd.img ] && [ -s $IMG/filesystem.squashf
|
||||
ok "present, kept"
|
||||
elif [ -n "$IMAGE_URL" ]; then
|
||||
tmp=$(mktemp -d -p /srv/rollcall)
|
||||
curl -fsSL -o "$tmp/SHA256SUMS" "$IMAGE_URL/SHA256SUMS" || die "$IMAGE_URL/SHA256SUMS missing"
|
||||
for f in vmlinuz initrd.img filesystem.squashfs; do curl -fsSL -o "$tmp/$f" "$IMAGE_URL/$f"; done
|
||||
auth=(); [ -n "${IMAGE_TOKEN:-}" ] && auth=(-H "Authorization: token $IMAGE_TOKEN")
|
||||
pre=""
|
||||
if ! curl -fsSL "${auth[@]}" -o "$tmp/SHA256SUMS" "$IMAGE_URL/SHA256SUMS"; then
|
||||
pre=commissioning- # a release: the image files carry a prefix
|
||||
curl -fsSL "${auth[@]}" -o "$tmp/SHA256SUMS" "$IMAGE_URL/${pre}SHA256SUMS" || die "no SHA256SUMS or ${pre}SHA256SUMS at $IMAGE_URL"
|
||||
fi
|
||||
for f in vmlinuz initrd.img filesystem.squashfs; do curl -fSL --progress-bar "${auth[@]}" -o "$tmp/$f" "$IMAGE_URL/$pre$f"; done
|
||||
(cd "$tmp" && sha256sum -c --quiet SHA256SUMS) || die "checksum mismatch"
|
||||
mv "$tmp"/vmlinuz "$tmp"/initrd.img "$tmp"/filesystem.squashfs "$tmp"/SHA256SUMS $IMG/ && rm -rf "$tmp"
|
||||
chmod 0644 $IMG/*
|
||||
|
||||
Reference in new issue
Block a user