#!/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). # With verify_server_hostname=true the RPC name is server..nomad # (NOT server...nomad) — region here is "global" (nomad.hcl). openssl req -newkey rsa:2048 -nodes \ -keyout server.key -out server.csr \ -subj "/CN=server.global.nomad" cat > server.ext <