The stack's settings are repo variables, its secrets repo secrets, and NATS_PASSWORD an org secret the content repo can share. The deploy workflow checks they are all set, writes .env, portal.env, nats.env and chat.env into the runner's own directory, and the root script (now in the repo as deploy-tomtervel) pulls main, puts them in place as root's and brings the stack up. So nothing is edited on the host or committed: a host name or a version is a variable changed and a Run workflow. nats.conf reads NATS_PASSWORD from its environment, so it is committed rather than rendered. bootstrap.sh only makes Kanidm's config and certificate and recovers its admins; kanidm-setup.sh reads portal.env, and leaves the two secrets it makes in kanidm-setup.secrets for gt. The DNS workflow uses actions/checkout and actions/cache (the runner's cache server) for dnscontrol, at the DNSCONTROL_VERSION variable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
This commit is contained in:
12 files changed
+282
-207
No files matched your search
@@ -20,14 +20,18 @@ so nothing about the vel's members or records depends on anyone else.
|
||||
## First start
|
||||
|
||||
On a fresh Linux host with podman + podman-compose and openssl (run rootful,
|
||||
i.e. as root, so Caddy can bind 80/443 and Kanidm sees a stable source IP):
|
||||
i.e. as root, so Caddy can bind 80/443 and Kanidm sees a stable source IP),
|
||||
with a Gitea runner on it, and the variables and secrets below set
|
||||
(`NATS_PASSWORD` is any long random string: `openssl rand -hex 24`):
|
||||
|
||||
```sh
|
||||
git clone https://prosjekt.klingenbergbygg.no/tomtervel/infrastructure /srv/tomtervel/infrastructure
|
||||
cd /srv/tomtervel/infrastructure
|
||||
cp secrets.env.example secrets.env # the hosts are in .env, committed; DNS must point here
|
||||
sudo sh bootstrap.sh # renders configs, makes the internal cert, starts, recovers Kanidm admin
|
||||
sh kanidm-setup.sh # logs in, creates the portal client and desk groups, restarts portal
|
||||
sudo install -m 0755 deploy-tomtervel /usr/local/bin/deploy-tomtervel # and the sudoers line in it
|
||||
sudo ID_HOST=id.tomtervel.no sh bootstrap.sh # Kanidm's config and certificate
|
||||
# Actions -> deploy -> Run workflow # the env files, and the stack up
|
||||
sudo sh bootstrap.sh # recovers the Kanidm admins, once
|
||||
sh kanidm-setup.sh # the portal client and desk groups; set the two secrets it names
|
||||
```
|
||||
|
||||
`bootstrap.sh` prints the `admin` and `idm_admin` passwords once;
|
||||
@@ -80,7 +84,7 @@ and is safe to rerun:
|
||||
- **Onboarding.** The `portal-onboarding` service account manages
|
||||
every desk group, so an invite from a desk and a `grants:` can add
|
||||
people to them. Its token goes into `portal.env`.
|
||||
- **The first person in.** `SEED_ADMIN_EMAIL` in `secrets.env`: at start,
|
||||
- **The first person in.** The `SEED_ADMIN_EMAIL` secret: at start,
|
||||
portal invites them into the most privileged group (the board) and
|
||||
mails the link, once. Everyone else they invite from their desk.
|
||||
- **The people who ask the questions.** Everyone a page names as
|
||||
@@ -124,28 +128,47 @@ Until then, `podman compose restart portal` picks up new content.
|
||||
|
||||
## Upgrading portal
|
||||
|
||||
Bump `PORTAL_RELEASE` in `.env` (a tag of uhhm/portal), commit and push
|
||||
to main: the deploy workflow brings it up. Keep `PORTAL_RELEASE` in the
|
||||
Set the `PORTAL_RELEASE` variable (a tag of uhhm/portal) and run the
|
||||
deploy workflow. Keep `PORTAL_RELEASE` in the
|
||||
content repo's `lint-and-reload.yml` matched to it.
|
||||
|
||||
## What is in git, and what is on the host
|
||||
## Variables and secrets
|
||||
|
||||
`.env` is committed: the hosts, the versions, where the content comes
|
||||
from - everything the stack *is*. `podman compose` reads it as it is,
|
||||
so a change to it is a commit, and a push to main deploys it. The repo is
|
||||
public, so nothing secret goes there.
|
||||
Every value the stack runs with is an Actions variable or secret in
|
||||
Gitea, never a file in the repo (it is public) and never edited on the
|
||||
host. The deploy workflow writes them into the env files on kasse
|
||||
(`.env`, `portal.env`, `nats.env`, `chat.env`) on every run, so a host
|
||||
name or a version is changed in Gitea, and then **Actions -> deploy ->
|
||||
Run workflow**. Set them with `gt` (`gt variable set NAME --body ...`,
|
||||
`gt secret set NAME`, `-o tomtervel` for the org's).
|
||||
|
||||
The secrets stay on the host, made there and never in CI: `secrets.env`
|
||||
(the NATS password, the OAuth2 secret, the first person's address; see
|
||||
`secrets.env.example`), and what the scripts render from it - `portal.env`,
|
||||
`nats.env`, `chat.env`, `nats/nats.conf`, `kanidm/server.toml`.
|
||||
`bootstrap.sh` and `kanidm-setup.sh` read `.env` and then `secrets.env`.
|
||||
| name | kind | where | what |
|
||||
|---|---|---|---|
|
||||
| `PORTAL_HOST`, `ID_HOST`, `CHAT_HOST` | variable | repo | the site, the login, the chat; each needs DNS (`dns/`) and a kasse Caddy block |
|
||||
| `PORTAL_RELEASE` | variable | repo | a uhhm/portal tag; keep the content repo's lint on the same |
|
||||
| `GDO_RELEASE`, `CNATS_TAG`, `KRON_RELEASE` | variable | repo | the mailer, the chat, the money service |
|
||||
| `COMPOSE_PROFILES` | variable | repo | `chat` |
|
||||
| `CONTENT_REPO`, `CONTENT_BRANCH` | variable | repo | the content this site serves |
|
||||
| `SITE_NAME` | variable | repo | `tomtervel`; never changed (a new name is a new, empty site) |
|
||||
| `PEOPLE_BACKEND`, `RESPONSIBLE_GROUP` | variable | repo | `memberships`, `redaktor` |
|
||||
| `OAUTH2_CLIENT_ID`, `CHAT_OAUTH2_CLIENT_ID` | variable | repo | the Kanidm clients of the site and the chat |
|
||||
| `NATS_ADOPT_LEGACY` | variable | repo | `sole` |
|
||||
| `GARAGE_S3_ENDPOINT`, `GARAGE_UPLOADS_BUCKET` | variable | repo | uploads |
|
||||
| `NATS_PASSWORD` | secret | **org** | the stack's NATS; the content repo's reload uses it too |
|
||||
| `OAUTH2_CLIENT_SECRET`, `KANIDM_API_TOKEN` | secret | repo | made by `kanidm-setup.sh`, which says how to set them |
|
||||
| `CHAT_OAUTH2_CLIENT_SECRET` | secret | repo | the chat's Kanidm client |
|
||||
| `GARAGE_ACCESS_KEY`, `GARAGE_SECRET_KEY` | secret | repo | uploads |
|
||||
| `SEED_ADMIN_EMAIL`, `SEED_ADMIN_NAME` | secret | repo | the first person in; an address, so not a variable |
|
||||
| `CLOUDFLARE_API_TOKEN` | secret | repo | DNS edit for tomtervel.no only (`dns/`) |
|
||||
| `DNSCONTROL_VERSION` | variable | repo | the DNS workflow's dnscontrol |
|
||||
|
||||
`kanidm/server.toml` takes `ID_HOST` when `bootstrap.sh` renders it, not on
|
||||
a deploy: Kanidm's domain is renamed on purpose, once (see dns/README.md).
|
||||
A variable is printed wherever a workflow echoes it, and this repo's run
|
||||
logs are public: a value that must not be read is a secret.
|
||||
|
||||
The one secret in Gitea is the repo secret `CLOUDFLARE_API_TOKEN`, for
|
||||
the DNS workflow.
|
||||
What is not a value stays on the host, made there once: Kanidm's config
|
||||
and internal certificate (`bootstrap.sh`), and Garage's node secret.
|
||||
`kanidm/server.toml` takes `ID_HOST` once: Kanidm's domain is renamed on
|
||||
purpose, not by a variable changed (see dns/README.md).
|
||||
|
||||
## Backups
|
||||
|
||||
|
||||
Reference in new issue
Block a user