diff --git a/deploy/nomad/README.md b/deploy/nomad/README.md index 3b72be3..2c8d86c 100644 --- a/deploy/nomad/README.md +++ b/deploy/nomad/README.md @@ -82,9 +82,18 @@ sudo cp deploy/nomad/nomad.hcl /etc/nomad.d/nomad.hcl ## 3. Generate TLS material The API is reachable from the internet (Forgejo runner → VPS), so TLS is -mandatory. One mini-CA + one server cert; the runner gets **only** the CA -cert. +mandatory. Use the script (CA + server cert with all required SANs in one +shot — hand-rolled openssl commands tend to miss `server.global.vps.nomad`, +which `verify_server_hostname` requires): +```bash +sudo deploy/nomad/gen-tls.sh +sudo systemctl restart nomad +``` + +The runner gets **only** the CA cert (`nomad-ca.crt`) as `NOMAD_CACERT`. + +Manual equivalent (what the script does): ```bash cd /tmp && mkdir nomad-tls && cd nomad-tls diff --git a/deploy/nomad/gen-tls.sh b/deploy/nomad/gen-tls.sh new file mode 100644 index 0000000..ea67d4a --- /dev/null +++ b/deploy/nomad/gen-tls.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# Regenerate Nomad TLS material for the single-node agent. +# +# Usage (on the services VPS, from the repo root): +# sudo deploy/nomad/gen-tls.sh +# +# Produces /etc/nomad.d/tls/{nomad-ca.crt, server.crt, server.key} and leaves +# the new CA in a temp dir for copying to the Forgejo runner (NOMAD_CACERT). +# Requirements: SAN must contain server.global.vps.nomad (region.global, +# datacenter vps — matches deploy/nomad/nomad.hcl) + the addresses clients +# use to reach the API. + +set -euo pipefail + +ip="${1:?usage: gen-tls.sh }" + +tls_dir=/etc/nomad.d/tls +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT +cd "$work" + +# 1. mini CA +openssl req -x509 -newkey rsa:2048 -nodes -days 3650 \ + -keyout nomad-ca.key -out nomad-ca.crt \ + -subj "/CN=Contract-Check Nomad CA" + +# 2. server cert (serverAuth+clientAuth: the agent uses it for both roles) +openssl req -newkey rsa:2048 -nodes \ + -keyout server.key -out server.csr \ + -subj "/CN=server.global.vps.nomad" + +cat > server.ext <