Skip to content

Devops handover


title: Prepare, approve and support a hotel install description: The manual DevOps steps around a hotel install: one-time setup, each install, approval, updates, removal and restore. audience: internal type: how-to owner: platform-team last_reviewed: 2026-11-19


Everything the Castis DevOps team does by hand around an install: before sending it to someone, while they install, and after. The installer's side is in Install on your own server.

What each step does, and which values it fills in, is explained in end-to-end.md (Part B, step by step). This file is the checklist with the commands.

Who Does what
You (DevOps) Prepare the repo once. For each install, create a one-time tailnet key and send the handover message. Afterwards, name and check the site
Installer (on site) Clones the repo, runs ./install.sh, pastes the credentials you sent
Wizard (automatic) Asks the owner for company, address, email and admin password; generates every other password; hands the site to Argo CD

Headscale commands below are for the Headscale server. If it runs in Docker, put docker exec -it <container> in front of each one (e.g. docker exec -it headscale headscale users list). Some flags differ between Headscale versions; when a command is rejected, check headscale <command> --help.


Part 1 — One-time setup (first install only)

1.1 Fill in the shared values in the repo

These are the same for every site. Everything else (domain, passwords, org, admin user) is filled in per site by the wizard. Don't replace the ${IBC_…} placeholders or your-domain.example.com; they stay in git.

✓ File Value What to put
[ ] setup-agent/defaults.env IBC_CLOUD_URL Public URL of the Castis edge API in coreapi (edge-api.md). Warning: Until coreapi has it, installs stop at "Approval by Castis"
[ ] setup-agent/defaults.env IBC_PARENT_DOMAIN The zone site addresses are built under (castis.io → ariyana.castis.io). coreapi's Cloudflare token must be able to edit it
[ ] setup-agent/defaults.env IBC_ACMEDNS_HOST Your acme-dns API URL (default https://acme.castis.io)
[ ] cert-manager/02-clusterissuer.yaml email Team email for Let's Encrypt expiry notices
[ ] application/*/overlays/kustomization.yaml newTag The tested app versions every site will run

Pinned versions: versions.env holds every base version (k3s, Helm, the APISIX chart, cert-manager), and at the bottom, every image that must be in Nexus. See 1.7.

Already set, nothing to fill in: the Nexus logins are the same for every site and already in the repo: - registry-secret.yml: image pull login for registry.nexus.castis.io - prerequisite.sh NEXUS_HELM_USER / NEXUS_HELM_PASS: Helm repo login for the APISIX and cert-manager charts. Warning: It's helm with a password kept in prerequisite.sh (NEXUS_HELM_PASS), which may be an account that can upload. Replace it with a pull-only Helm user, as was done for images.

Only touch them if the Nexus accounts change. Changing one breaks installed hotels unless you update them too: each machine copied the pull login at install (into /etc/rancher/k3s/registries.yaml, the IBC_REGISTRY_DOCKERCONFIG_B64 value in Secret argocd/ibc-site, and Secret nexus-registry-secret in ingress-apisix, cert-manager and kube-system). Rotate by adding the new account first, updating every hotel (see Rotate the Nexus pull login in Part 3), and removing the old account last.

registry-secret.yml holds the pull-only user regis-read, since every hotel receives it (checked: it can read images, and pushing is refused with 403). The Castis team pushes with its own account (e.g. docker-deployer, per playtelly-iac's Nexus user guide), never this one. - regis-read's password equals its name, so anyone could guess it and pull your images. Consider a random password. - The previous login, which could push, is still in the git history. Change that account's password.

Not in the repo any more: the Cloudflare token. Sites never get it. It lives only in coreapi, which uses it when a site is approved (edge-api.md).

Quick check (run in the repo). This must show your real edge API URL, not '':

grep -n 'IBC_CLOUD_URL\|IBC_PARENT_DOMAIN\|IBC_ACMEDNS_HOST' setup-agent/defaults.env

1.2 Publish the branch sites will follow

Every site auto-updates from this branch, so only merge tested changes into it.

main holds the installer (the old feature/argocd-installer branch is merged into it) and is the lab channel (Part 3). Once a VM test install from main passes, create the release branch that sites follow:

git checkout -b stable && git push -u origin stable

Create canary the same way when you have a pilot hotel, and protect both branches (Part 3). From then on: changes land on main, and reach hotels only by promoting main → canary → stable (Part 3).

1.3 Create a GitLab deploy token

GitLab → project playtelly/ibc-iac → Settings → Repository → Deploy tokens → Add token: - Name: ibc-sites - Scopes: read_repository only - Expiry: none, or a long one. Argo CD on every site uses this token to pull updates, so an expired token stops all updates.

Save the username and token in your password manager. The same token works for git clone and for Argo CD.

1.4 Create a Headscale user for sites

This keeps site servers separate from the team's own devices.

headscale users create sites
headscale users list

Note the ID of sites. Newer Headscale versions use the ID instead of the name in --user.

1.5 (Optional) Create keys from your laptop instead of the server

By default you SSH to the Headscale server for every key (2.1). Headscale also has an API key, so you can create site keys remotely.

Once, on the Headscale server, create the API key. It's printed only once:

headscale apikeys create --expiration 90d

Store it in your password manager. It has full admin power over the tailnet (it can add nodes and change everything), so never put it in the repo, a chat or a shared file. When it expires, create a new one. To list or revoke keys:

headscale apikeys list
headscale apikeys expire --prefix <first chars of the key>

Then, from your laptop, create a site key through Headscale's REST API:

export HEADSCALE_API_KEY='<api key>'
curl -s -X POST https://headscale.castis.io/api/v1/preauthkey \
  -H "Authorization: Bearer $HEADSCALE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"user\":\"sites\",\"reusable\":false,\"ephemeral\":false,\"expiration\":\"$(date -u -v+24H +%Y-%m-%dT%H:%M:%SZ)\"}"

  • date -v+24H is macOS syntax. On Linux use date -u -d '+24 hours' +%Y-%m-%dT%H:%M:%SZ.
  • On newer Headscale versions "user" is the numeric ID of sites (1.4), e.g. "user": 3.
  • The key is in the response's preAuthKey.key field.
  • If the request is rejected, check your version's API docs at https://headscale.castis.io/swagger (available in most versions).

(The headscale CLI also has a remote mode, HEADSCALE_CLI_ADDRESS + HEADSCALE_CLI_API_KEY, but it uses gRPC, which your reverse proxy in front of Headscale may not pass through. The REST call above is the simpler option.)

Warning: Without a policy, Headscale lets every node reach every other node, so one compromised site could reach all the others and your servers.

Target rules: only Castis → site is allowed over the tailnet.

Castis team (group:ops) ──► sites   SSH 22, HTTPS 443, k8s API 6443, wizard 8800
sites ──✗──► anything on the tailnet (other sites, team laptops, Castis servers)

Sites never start a connection over the tailnet. They reach Castis the same way they already reach GitLab and Nexus: over public HTTPS URLs. A compromised site then has no way into the tailnet. Replies to connections your team opens still work, because the rules are stateful.

Draft policy. The user-name format in groups and tag support depend on your Headscale version, so check against its docs before applying:

{
  "groups": {
    "group:ops": ["<your-headscale-user>@", "<teammate>@"]
  },
  "tagOwners": {
    "tag:site": ["group:ops"]
  },
  "acls": [
    // Castis team -> every site. There are no rules with a site as the
    // source, so sites can't reach anything on the tailnet.
    { "action": "accept", "src": ["group:ops"], "dst": ["tag:site:22,443,6443,8800"] }
  ]
}

With this policy in place, add --tags tag:site to the key command in 2.1 (if your version supports tags on pre-auth keys), so every new site is locked down automatically. Then test: - From a site: pinging another site's tailnet IP must fail, and so must pinging your laptop. - From your laptop: ssh <user>@<site tailnet IP> must work.

For the future broker: because sites reach it over a public URL, not the tailnet, it can't identify a site by its tailnet identity. It has to authenticate each site itself, for example with a per-site token issued at install and bound to that site's subdomain. It also needs the usual protection for a public endpoint (HTTPS, rate limits, logging).

1.7 Copy images into Nexus (when a version changes)

Hotels pull every image from Nexus. Our manifests use Nexus paths directly, and k3s pulls the public-named images (Argo CD's, its own, and a few from the Helm charts) through Nexus (/etc/rancher/k3s/registries.yaml, written by prerequisite.sh). If a public-named image is missing from Nexus, k3s quietly pulls it from the public registry instead, so a forgotten copy doesn't fail; it just leaves Nexus. So whenever a version or image changes (in versions.env, gitops/argocd/, a helper image in a manifest, or an app's newTag), copy the new images before installing with them. The full list is at the bottom of versions.env.

Keep each image's path and tag; drop the registry host and a leading library/ or docker/library/. Use the team's usual method, which copies all architectures registry to registry:

docker login registry.nexus.castis.io
docker buildx imagetools create -t registry.nexus.castis.io/argoproj/argocd:v3.1.0 quay.io/argoproj/argocd:v3.1.0
Check that both amd64 and arm64 landed:
docker buildx imagetools inspect registry.nexus.castis.io/argoproj/argocd:v3.1.0

For a new k3s version, its system images are listed in that release's k3s-images.txt on GitHub.


Part 2 — Every install

2.1 Create a one-time tailnet key

On the Headscale server (or from your laptop with the API key, see 1.5):

headscale preauthkeys create --user sites --expiration 24h

(Newer versions: --user <ID of sites>. With the ACL policy: add --tags tag:site.)

What makes it one-time: - No --reusable: it works for exactly one machine. - --expiration 24h: if it's never used, it's dead after a day. - No --ephemeral: an ephemeral node is removed when it goes offline, which is wrong for a server.

Check it, or cancel one sent by mistake:

headscale preauthkeys list --user sites
headscale preauthkeys expire --user sites <key>

2.2 Send the handover message

Send the credentials over a private channel, not a group chat or email thread with others in it:

Hi, here's everything for the TellyBoard server install.

Before you start:
- The Mac mini host with VirtualBox, connected by Ethernet, FileVault off,
  and a Debian 13 VM with a *bridged* network adapter (see VM-Setup.md).
- After the install, run host/macos/setup-host.sh once on the Mac mini
  (VM-Setup.md Part 7) so everything comes back after a power cut.

Credentials (you'll be asked for these):
- Git username:   <deploy token username>
- Git token:      <deploy token>
- Tailnet key:    <one-time pre-auth key>   (valid 24 hours, single use)
- Approval token: <from the Console>        (valid 24 hours, entered in the
                  wizard when it shows "Waiting for approval")

On the server, run:
  sudo apt update && sudo apt install -y git
  git clone -b stable https://mashup.castis.io/playtelly/ibc-iac.git
  cd ibc-iac && ./install.sh

When asked, enter the git username/token (twice: for the clone and for install.sh)
and the tailnet key. At the end it prints a web address and a 6-digit setup code:
open that address from any device on the same network, enter the code, and follow
the steps. Keep the sign-in details shown at the end.

If anything fails, send me a screenshot of the error.

Record the install in your site register (2.7) now: site name, date, and which key you sent.

2.3 While they install

They see / ask What to tell them
"Could not read branch … with those credentials" Wrong token, or the branch isn't pushed (1.2)
tailscale up fails / key rejected The key was already used or has expired. Create a new one (2.1)
Lost the setup code On the server: sudo cat /etc/ibc/setup-code
Wizard page won't open Check they're on the same network, using port 8800. On a NAT VM, host port 8800 must be forwarded to the VM
Wizard says "Waiting for approval" Send them an approval token (2.4), if they don't have one. Setup continues as soon as they enter it
"No Castis edge API configured" IBC_CLOUD_URL is empty (1.1), or coreapi doesn't have the edge API yet
Wizard shows a failed step Read the error and log on the page, then press Retry (every step is safe to repeat)
Wizard page gone after setup Expected: it closes when the owner clicks "close setup", or 24 h after finishing

Once the machine has joined the tailnet (early in install.sh), you can also help directly:

ssh <user>@<tailnet IP>
sudo journalctl -u ibc-setup -f

2.4 Approve the site

Not built yet

The edge API and the Playtelly Console screens it needs (approval tokens, license renewals, revoking a site) do not exist in coreapi yet. See Edge API. Until they do, a real install stops at Waiting for approval. For a test install, use the mock edge API at the end of this step.

The steps below describe the approval flow once the edge API exists.

A site is approved only with an approval token (edge-api.md, Castis side: approval tokens). There's no approve button for registrations.

  1. In the Playtelly Console (coreapi), create an approval token. It holds no customer details and is valid for 24 h and 3 uses by default.
  2. Send it to the installer over a private channel, with the handover message (2.2) or when they reach the wizard's "Waiting for approval" box.
  3. When the owner presses Install, the wizard registers the site with the edge API and waits. The installer enters the token in the Approval token box; coreapi checks it and approves the registration on the spot.
  4. Afterwards, check the registration in the Console: company, address (ariyana.castis.io), owner email, and that the subdomain is really meant for this customer. If it isn't, reject or revoke it with a reason.

On approval, coreapi: - issues the site's license bundle (license key + key pair). The repo holds no license - creates the site's acme-dns account - creates _acme-challenge.<address> CNAME in Cloudflare with its own token - hands the site only its acme-dns account and license

The wizard checks again as soon as the token is accepted, then issues the certificate and continues. If a registration is rejected, the installer sees your reason and can press Retry to register again.

Test install with the mock edge API. Run the mock on a machine the site can reach and set IBC_CLOUD_URL to it:

python3 setup-agent/dev/mock_edge_api.py --port 9900
Then create an approval token with curl -X POST http://<mock>:9900/admin/approval-tokens and enter it in the wizard's Approval token box. Its acme-dns accounts are fake, so the certificate step can't succeed with it; it only exercises the wizard flow.

2.5 After the install

0. Make the host survive power cuts. On the Mac mini: sudo host/macos/setup-host.sh "<VM name>", then do the three power-cut tests in Prepare a VM (VM shutdown, Mac reboot without logging in, power cable). The VM side was already done by install.sh (Step 0b).

1. Find and name the node. install.sh names it ibc-<hostname>, which is often ibc-debian, so rename it after the site's subdomain:

headscale nodes list
headscale nodes rename -i <node-id> site-ariyana

2. Check the site over the tailnet:

ssh <user>@<tailnet IP>

On the site, check that all apps are Synced + Healthy:

kubectl -n argocd get applications

Check the certificate is Ready:

kubectl get certificate -A

Check APISIX keeps the phone's real LAN IP (it must print Local; with Cluster every client shows as <POD_NETWORK_GATEWAY_IP>):

kubectl get svc apisix-gateway -n ingress-apisix -o jsonpath='{.spec.externalTrafficPolicy}'
This setting assumes single-node k3s. On a multi-node cluster, set it back to Cluster in apisix/apisix-values.yaml, or make sure APISIX runs on every node, otherwise traffic sent to a node without an APISIX pod is dropped.

3. Optional: open the Argo CD UI. Run the port-forward on the site, then an SSH tunnel from your laptop, and open https://localhost:8080:

kubectl -n argocd port-forward svc/argocd-server 8080:443
ssh -L 8080:localhost:8080 <user>@<tailnet IP>

Sign in as admin with the password from:

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d

4. Confirm the key is spent: headscale preauthkeys list --user sites should show it as used.

2.6 Give the site a backup target

Paused: Switched off for now (not in gitops/apps/kustomization.yaml) until Castis decides where hotel backups are stored. The component stays in gitops/components/backup/; to switch it on, uncomment - backup.yaml in gitops/apps/kustomization.yaml.

Backups stay off until a hotel has a backup target.

Once coreapi has it, this happens automatically: the first check-in (within an hour) delivers it (edge-api.md → Backup target).

Until then, set it by hand. Create a bucket/prefix and credentials for the hotel only, plus a random password (openssl rand -hex 32). Then, on the site over the tailnet, add these four lines to the site's values, following Change a value that lives on the machine (end of Part 3):

IBC_BACKUP_REPOSITORY='s3:https://<storage>/ibc-backups/<hotel>'
IBC_BACKUP_ACCESS_KEY='…'
IBC_BACKUP_SECRET_KEY='…'
IBC_BACKUP_PASSWORD='…'

Test it right away instead of waiting for 02:30:

kubectl -n seaweedfs create job --from=cronjob/ibc-backup backup-now
kubectl -n seaweedfs logs -f job/backup-now -c restic

Result: It ends by listing a snapshot. Store the four values in the site register / password manager. Without them the hotel can't be restored.

2.7 Site register

Keep one row per site (spreadsheet or a private doc, not this repo):

Site Address Registration Headscale node Tailnet IP Branch Installed Approved by Backup repository (+ keys/password in the password manager) Notes
Ariyana Resort & Spa ariyana.castis.io reg_8f2a… site-ariyana (id 12) stable 2026-10-01 s3:https://…/ibc-backups/ariyana

Part 3 — Rolling out updates

All updates are merges in this repo. The steps, per kind of change: end-to-end.md Part F. The DevOps side:

  1. Channels: hotels follow main (lab VM), canary (1 pilot hotel) or stable (everyone else), chosen with git clone -b at install. Protect canary and stable in GitLab (Settings → Repository → Protected branches) so they change only through MRs.
  2. Before promoting:
  3. All hotels on that channel are Synced + Healthy (kubectl -n argocd get applications over the tailnet).
  4. The change is tested on the lab VM.
  5. New variables have defaults and a row in site-variables.md.
  6. Promote: MR main → canary, watch the pilot hotel for 1–2 days, then MR canary → stable. Update the site register's version column.
  7. Per-hotel setting: add or edit sites/<hotel>/site.env (site overrides) and merge it to that hotel's branch.
  8. Rollback: revert the merge on the affected branch.
  9. License renewals (not built yet: needs the edge API): nothing to do on the hotels. Each one checks in hourly and picks up a renewed license by itself. Your part is in the Console:
  10. approve renewal requests for sites set to manual
  11. watch the alerts: licenses expiring, and sites that stopped checking in
  12. Backups: watch the alerts for sites whose last successful backup is older than ~2 days. On a site, backupLastSuccess is in the status below. Once in a while, do a test restore onto a spare VM (Part 5), to prove the backups really work.
  13. A site's last check-in, seen from the site (over the tailnet):
    kubectl -n argocd get configmap ibc-agent-status -o yaml
    
    Or trigger one right away:
    kubectl -n argocd create job --from=cronjob/ibc-agent ibc-agent-manual
    

Change a value that lives on the machine

For the generated passwords and keys (S3, Valkey, MQTT, the authapi/coreapi key, the JWT secrets) use ./scripts/change-password.sh instead: see Change a password, and see who did it below. The steps here are for any other value, e.g. setting the backup target by hand. Over the tailnet, on the site, copy the site's values out of the live Secret:

kubectl -n argocd get secret ibc-site -o jsonpath='{.data.site\.env}' | base64 -d > /tmp/site.env
Edit /tmp/site.env (change or add lines like IBC_VALKEY_PASSWORD='value'), then put it back, re-render, and delete the copy:
kubectl -n argocd create secret generic ibc-site --from-file=site.env=/tmp/site.env --dry-run=client -o yaml | kubectl apply -f -
kubectl -n argocd rollout restart deployment/argocd-repo-server
rm /tmp/site.env
kubectl -n argocd rollout status deployment/argocd-repo-server
kubectl -n argocd annotate applications --all argocd.argoproj.io/refresh=hard --overwrite
The hard refresh matters: git didn't change, so without it Argo CD may keep using its cached render. The affected pods then restart by themselves. Edit the Secret, not /etc/ibc/site.env: after install the Secret is the live copy (the check-in agent updates it), and the file may be out of date. Postgres, Zitadel's master key, org and admin user are only read on first start (archive/docs/configuration.md Section 21). Changing them later has no effect, which is why the wizard locks them.

Find a site's passwords

On the site (over the tailnet), from the repo folder:

sudo ./scripts/show-secrets.sh
It prints every credential with a plain label: the owner's sign-in, PostgreSQL (postgres and zitadel users), Zitadel's master key, S3, Valkey, the authapi/coreapi secrets, the edge API identity, the acme-dns account, the backup target, Argo CD's admin password and the setup code, plus how to open a psql shell. --save <file> also writes them to a file only you can read; delete it (shred -u <file>) once they're in the password manager. It reads Secret argocd/ibc-site, the live copy, and falls back to /etc/ibc/site.env.

Change a password, and see who did it

Changing a production password should be on record. On the site, from the repo folder, as your own user (not root):

./scripts/change-password.sh
A menu lists what can be changed here (S3 keys, Valkey, the two MQTT passwords, the authapi/coreapi key, the two JWT secrets, the JWT RSA signing key), with who changed each last. Pick one; the script shows what will restart and what people will notice, asks for a reason or ticket number, and asks you to type the item's name to confirm (change for a batch). Then it makes a new random value (or uses one you type, see below), saves the old one (root only, last 10 kept in /var/lib/ibc/secret-backups), updates the ibc-site Secret and /etc/ibc/site.env, lets Argo CD restart what uses it, and waits for that.

  • ./scripts/change-password.sh valkey --reason "ticket 123" skips the menu; --dry-run shows the plan and changes nothing.
  • ./scripts/change-password.sh --rollback puts a saved old value back (also on record). If the variable did not exist before (the RSA key on an older hotel), the rollback removes it again.
  • Several at once, or all: at the menu type 1,3,5, a few names, or all. Or from the command line: ./scripts/change-password.sh valkey mqtt psk --reason "ticket 123", or --all (everything, random values). One reason, one summary of what restarts and what people will notice, one confirmation (type change), one restart round (a workload that uses several of them restarts once). The old values of the whole batch are saved together, so --rollback puts all of them back, and the audit lines share a [batch ...] label. Do a big batch in a quiet window: storage, VerneMQ, Valkey, coreapi and authapi all restart, everyone is signed out, and TVs may stay disconnected until they restart.
  • Your own value instead of a random one: for each value the script asks you to type one, or press Enter and a random one is made (there is no separate question). On a terminal a live checklist updates on every key (typing is hidden, Enter is accepted only when every line is ticked, Esc cancels), then you type it again. The rules: letters and digits only (the value goes into YAML, JSON and command lines); length 12-128 for Valkey and the MQTT passwords, 16-64 for the two S3 keys, 32-128 for the authapi PSK and the two JWT secrets (they sign and authenticate); at least 6 different characters; not the current value. For the RSA key you give the path of a PEM file instead (Enter generates one): an unencrypted RSA private key of at least 2048 bits, stored as base64 of the PKCS#8 PEM; a wrong path or file is refused with the reason, 3 tries. The rules live in scripts/lib/ibc-input.py. The audit line says [own value]. --random skips the question.
  • Run without a name, it first prints every password and key this site has (that is scripts/show-secrets.sh, so the view is logged), then the menu. --no-show skips the printout; the menu's s prints it again.
  • Not changed here, and the menu says why: Postgres and the Zitadel passwords and master key (read on first start only), the coreapi encryption key and the site master key (stored data would become unreadable), the owner's sign-in (the owner changes it in the app) and Argo CD's admin password (argocd account update-password).

Who did what: every change, rollback, refusal and every run of scripts/show-secrets.sh is written to /var/log/ibc/audit.log (root only) and to the system journal (journalctl -t ibc-audit), as one JSON line: when, the person (the login, not "root"), the address they came from, what, the result and the reason. Never the value: only a fingerprint (the first 8 characters of its sha256) to tell versions apart. The script writes a "started" line before it changes anything and stops if it can't.

sudo ./scripts/audit-log.sh                         # the last 50 events
sudo ./scripts/audit-log.sh --since 2d --user alice
sudo ./scripts/audit-log.sh --target IBC_VALKEY_PASSWORD
sudo ./scripts/audit-log.sh --failed
sudo ./scripts/audit-log.sh --newest-first          # the latest event on top
sudo ./scripts/audit-log.sh -f                      # watch new events live, like tail -f (Ctrl+C)
sudo ./scripts/audit-log.sh --check                 # does the file match the journal?
sudo ./scripts/audit-log.sh --since 30d --csv --out ~/audit-november.csv   # export for a review (opens in Excel)
--csv and --json print to the screen (redirect them if you like), and --out <file> writes the file, readable only by you, with a SHA-256 hash printed: keep the hash with the file to show it was not edited. An export is not cut to the last 50 events unless you add --tail. --until <date> closes a range. For many hotels, ship /var/log/ibc/audit.log to the central log store (Vector) instead of exporting by hand. Which scripts are recorded: viewing the passwords (show-secrets.sh), changing one (change-password.sh, one line per password) and running a script that changes the machine: install.sh, prerequisite.sh, restore.sh, reset.sh and change-ip.sh (action run, target the script, a started line and then ok, failed or cancelled, with the options as the reason). A script started by another one (install.sh runs prerequisite.sh) is recorded once, by the outer one; the setup wizard's own prerequisite.sh run shows as user root. --help, --dry-run and answering "no" to reset.sh write nothing. reset.sh, restore.sh and change-ip.sh refuse to run if the log cannot be written (set IBC_AUDIT_OPTIONAL=1 to run anyway on a broken machine or a lab); install.sh and prerequisite.sh only warn, because they set the logging up on a new machine. reset.sh never deletes /var/log/ibc. Not recorded on purpose: render.sh (Argo CD runs it all the time), the release and test tools, and audit-log.sh itself.
sudo ./scripts/audit-log.sh --action run          # who ran which script, and how it ended

How long it is kept: the file is rotated every month, compressed, and kept for 12 months (/etc/logrotate.d/ibc-audit, set up by prerequisite.sh Step 0b: new installs get it; an existing hotel gets it by re-running PREREQ_PHASE=base ./prerequisite.sh, or by hand below). audit-log.sh reads the old files too, so --since and --csv reach back the whole year. The system journal is only a short-term second copy (size-limited), so --check compares just the period the journal still covers. To keep more than 12 months, change rotate 12, or ship the log off the box.

sudo apt install -y logrotate && sudo install -d -m 750 /var/log/ibc
printf '%s\n' '/var/log/ibc/audit.log {' '    monthly' '    rotate 12' '    dateext' '    compress' '    delaycompress' '    missingok' '    notifempty' '    create 0640 root root' '}' | sudo tee /etc/logrotate.d/ibc-audit
sudo logrotate -d /etc/logrotate.d/ibc-audit      # dry run: shows what it would do, changes nothing

A line in the file that isn't valid JSON is always shown as UNREADABLE LINE, whatever the filters: someone edited the file by hand. This log is a record, not a lock: root can still edit it, which is why the journal keeps a second copy and --check compares them. For a central record across hotels, see the secrets item in edge-api.md.

Give a hotel its own JWT signing key (authapi)

Every hotel signs its sign-in tokens (authapi) with its own RSA key. It used to be one built-in key, shared by every hotel and written in git, so anyone with the repo could sign a token for any hotel. Now application/authapi/overlays/secret.yml reads ${IBC_JWT_RSA_PRIVATE_KEY} from the site's own values, and the old literal key is gone from the files.

  • New installs get the key from the setup wizard (RSA-2048, made with openssl). Nothing to do.
  • A hotel installed before that must have the key before it follows a version of the repo that contains this change. Without it, Argo CD cannot render authapi (unresolved values ... ${IBC_JWT_RSA_PRIVATE_KEY}); the running authapi keeps running, but nothing can be updated. Create it once, on that hotel, from the repo folder (after git pull):
    ./scripts/change-password.sh jwt_rsa --reason "per-hotel JWT key"
    
    Check: sudo ./scripts/show-secrets.sh | grep "JWT RSA" shows set, fingerprint ....
  • Roll it out by branch: main is the lab, canary the pilot hotel, stable everyone else. Merge this change into canary and stable only after every hotel on that branch shows the key as set. A hotel that gets the change with the key set restarts authapi once, and everyone is signed out once.
  • Rotating it later: ./scripts/change-password.sh jwt_rsa makes a new key, restarts authapi and waits (everyone is signed out). To use your own key, give the path of a PEM file when asked: an unencrypted RSA private key of 2048 bits or more.

Still open: the old shared key stays in git history, so treat it as exposed (it is also in playtelly-iac, services/access/authapi/overlays/prod/secret.yml, which must be replaced there too). Per-site issuer and audience, and keys kept in AuthAPI's own database, are in playtelly-iac/docs/edge/credential-lifecycle.md section 9.

Keep the cluster's admin credential out of people's home folders

The scripts (install.sh, prerequisite.sh, restore.sh, scripts/change-ip.sh, scripts/change-password.sh, the partner enrollment) no longer copy the k3s admin kubeconfig into the user's ~/.kube/config. They run kubectl and helm through sudo with root's own file (/etc/rancher/k3s/k3s.yaml, root only), via scripts/lib/ibc-kube.sh. So no admin credential sits in anyone's home folder, and every cluster command is on the system's sudo record under the person's name (/var/log/auth.log).

  • Day to day people type sudo kubectl ... (k3s's kubectl finds root's file itself) and sudo env KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm ....
  • The old way (a copy in ~/.kube/config) is still there for a lab or a migration: IBC_KUBE_ACCESS=copy ./install.sh. The setting is passed on to the scripts a script starts.
  • A site installed before this change still has its ~/.kube/config. The scripts ignore it now. Once a site runs the new scripts, remove it: rm ~/.kube/config (and the KUBECONFIG line in ~/.bashrc).
  • The setup wizard is unaffected: its service already runs as root with /etc/rancher/k3s/k3s.yaml.

If the server's IP changes

CoreDNS, the node's own resolver and the cluster's coredns-custom are set up once (prerequisite.sh Step 8, run by the wizard) with the IP the server had then. When the IP changes (a DHCP lease, a new router), they keep answering with the old one and staff devices can't reach the address. Re-running install.sh does not fix this: it only runs Steps 0-6.

On the site, from the repo folder:

./scripts/change-ip.sh
It reads the site's values (the ibc-site Secret, falling back to /etc/ibc/site.env) and re-runs only the site phase of prerequisite.sh (Steps 7-8). With IBC_ANSWER_IP empty or auto it detects the current IP; a pinned one is used as is. Either way it saves the result as IBC_SERVER_IP (the one IP CoreDNS answers with and mediasoup announces), and restarts mediasoup so it announces the new IP. It is safe to repeat: the certificate step finds the existing acme-dns account and certificate. It prints the IP devices must use as their DNS server.

A hotel installed before IBC_SERVER_IP existed has no value for it, so its mediasoup app won't render until ./scripts/change-ip.sh has run once.

Then update the router's DHCP DNS setting (or each device's DNS) to the new IP.

  • Pin an IP: ./scripts/change-ip.sh <HOST_LAN_IP> sets IBC_ANSWER_IP in both the Secret and /etc/ibc/site.env, then applies it. Only for a VM behind NAT, where the detected IP isn't the one devices reach. A pinned IP doesn't follow later changes; ./scripts/change-ip.sh auto goes back to detecting it.
  • Make the problem go away: give the server a DHCP reservation in the router (or a static IP, set on the OS: the script doesn't change network settings). Leave IBC_ANSWER_IP as auto, run ./scripts/change-ip.sh once, and it stays right.
  • Check: dig @<new-ip> <domain> answers with the new IP.

Rotate the Nexus pull login

Create the new Nexus account first and keep the old one working. Update registry-secret.yml in git, then on each hotel, over the tailnet, from its repo clone after git pull: 1. PREREQ_PHASE=base ./prerequisite.sh rewrites /etc/rancher/k3s/registries.yaml and restarts k3s. Installs that already exist are skipped, but the checks re-run, including Step 5's test route (a few minutes). 2. Replace the copied secret in each namespace prerequisite.sh put it in:

for ns in ingress-apisix cert-manager kube-system; do kubectl -n $ns delete secret nexus-registry-secret && kubectl apply -f registry-secret.yml -n $ns; done
3. Set IBC_REGISTRY_DOCKERCONFIG_B64 to the new value (awk '/\.dockerconfigjson: *\|/{on=1;next} on&&/^[^ ]/{exit} on{sub(/^ /,"");print}' registry-secret.yml | base64 -w0), as in Change a value that lives on the machine above.

Remove the old account only when every hotel is done.


Part 4 — Removing a site

Contract ended, machine replaced or stolen:

  1. Cut its tailnet access. This takes effect immediately:
    headscale nodes list
    
    headscale nodes delete -i <node-id>
    
  2. Revoke the site in the Playtelly Console (coreapi). That removes its _acme-challenge CNAME and its acme-dns account, so its certificate stops renewing and the subdomain is freed.
  3. If the machine is being reused: on it, run ./reset.sh (it wipes the cluster, the site settings and the wizard), then sudo tailscale logout.
  4. If the machine was stolen or lost, also rotate the shared secrets it held:
  5. the GitLab deploy token (1.3), then update the other sites' Argo CD repo Secret
  6. the Nexus pull login

Sites hold no Cloudflare token, and their acme-dns account is revoked in step 2. 5. Update the site register.


Part 5 — Restoring a hotel on a new machine

When a hotel's server dies (disk, hardware, theft), bring it back as itself (same address, users, media, license) from its last nightly backup:

  1. Get the hotel's four backup values from the site register / password manager (later: from the Console).
  2. Prepare the new machine like a new install: Debian 13, the same fixed LAN IP as before if possible, and a new Headscale key (2.1). If the Mac mini host was replaced too, run host/macos/setup-host.sh on the new one (2.5 step 0).
  3. Run the base install:
    git clone -b <the hotel's branch> https://mashup.castis.io/playtelly/ibc-iac.git
    
    cd ibc-iac && ./install.sh
    
    Ignore the wizard address it prints.
  4. Restore:
    ./restore.sh
    
    It asks for the address prefix (ariyana) and the four backup values, lists the snapshots, and after you confirm it:
  5. turns off the wizard
  6. downloads the backup
  7. puts back the site's values, asking first whether devices should use a new LAN IP (only when the backup has a fixed IP rather than auto; Enter keeps the old one)
  8. gets the certificate and sets up local DNS
  9. loads Postgres
  10. restores SeaweedFS's volume and Zitadel's token
  11. hands over to Argo CD

To restore an older snapshot than the latest, set IBC_RESTORE_SNAPSHOT=<id> first. 5. Check: - kubectl -n argocd get applications: all Synced + Healthy, in 10–20 minutes - https://<hotel>.castis.io opens, and the owner can sign in with their existing password - the next check-in reaches Castis 6. Tidy up: - Delete the old machine's Headscale node, and rename the new one. - If the IP changed, update the router's DNS setting. - Note the restore in the site register.

What's lost: anything since the last nightly backup, plus what's never backed up (end-to-end.md Part F8). What's not needed: approval, or a new license. The restored values already contain them, and the site checks in as the same registration.

Security reminders

  • Headscale is the root of trust: whoever controls it can add nodes and change the ACL. Keep admin access to 1–2 people, back up its database, and keep it updated.
  • One key per install, never --reusable, always an expiry.
  • Site SSH: key-based login only.
  • Still open:
  • Sites no longer hold the Cloudflare token (it's in coreapi only). But the old token was committed to this repo before, so it's still in the git history. Rotate it in Cloudflare.
  • The old license key pair was also in the repo before it moved to the edge API, so it's in the git history too. Don't trust licenses signed with it.
  • coreapi's Zoho mail client secret (COREAPI_PLATFORM_EMAIL_CLIENT_SECRET) was committed in an early draft too. Rotate it in Zoho.
  • Each site still holds the Nexus login from the repo. Give repo access and installs only to people you trust.