updates / experimental TC setup

This commit is contained in:
2026-10-24 10:44:58 +02:00
parent 3c25fc5d41
commit d36b281a4d
48 changed files with 1147 additions and 718 deletions
+149 -52
View File
@@ -36,11 +36,42 @@ Quick reference:
| Monitoring | node_exporter → Pushgateway, Alloy → Loki (journal), Snipe-IT asset check-in (daily 03:30) |
| Rollout | Pilot: 3 hosts, 2 weeks; then 5 → 10 → rest |
## AZ-TC-01 pilot status
Confirmed infrastructure values for the pilot (`hosts/AZ-TC-01/default.nix`):
- AD DNS domain: `az-group.local`
- Kerberos realm: `AZ-GROUP.LOCAL`
- DCs: `azdc01.az-group.local` (`192.168.152.253`) and `adpdc01.az-group.local` (`192.168.152.254`)
- Computer objects currently use the default `CN=Computers` container.
- Pilot WiFi uses WPA-Personal SSID `Pluto`; `Saturn` EAP-TLS is deferred.
## Provisioning workflow for a new Fleet Host
Assuming you've copied `hosts/AZ-TC-01/default.nix` to
`hosts/AZ-TC-NN/default.nix`, updated `networking.hostName`, added the
flake entry, and committed.
Copy `hosts/AZ-TC-01/default.nix` to `hosts/AZ-TC-NN/default.nix` and
update the hostname, site, hardware class and target disk. Thin Client
host directories are discovered automatically; no manual flake entry is
required.
For a lab installation use `site = "staging"` and explicitly enable only
integrations whose infrastructure values and secrets are available. The
`production` site enables AD, WiFi, NetBird, RustDesk and monitoring by
default.
### Step 0 — Create the host age identity
Each host uses a dedicated age identity rather than its SSH host key. This
avoids a first-boot dependency on an SSH key that does not exist yet.
```bash
mkdir -p .secrets/identities
age-keygen -o .secrets/identities/AZ-TC-01.age
age-keygen -y .secrets/identities/AZ-TC-01.age
```
Add the printed `age1...` recipient to `secrets.nix` and use it as the host
recipient for all AZ-TC-01 secrets. The private identity is ignored by Git
and is copied to `/var/lib/agenix/identity.age` only during provisioning.
### Step 1 — Pre-create the AD computer account + keytab
@@ -48,49 +79,63 @@ Run from a host that can reach the AD DC (e.g. `AZ-LT-NIX`). Requires
`adcli` (available on the admin workstation via `nix-shell -p adcli` if
not installed).
Prerequisite: the target OU must exist in AD. If `OU=ThinClients,...`
doesn't exist yet, create it first (or omit `--domain-ou` to use the
default `CN=Computers,...` container).
For AZ-TC-01, no `ThinClients` OU exists yet, so the computer account is
created in the default `CN=Computers` container (omit `--domain-ou`).
```bash
# Pre-create the computer object in the ThinClients OU
adcli preset-computer \
--domain=az-group.local \
--domain-ou="OU=ThinClients,DC=az-group,DC=local" \
--os-name="NixOS" --os-version="26.05" \
--login-user=administrator \
AZ-TC-01.az-group.local
# Check AD discovery and clock before joining
nix shell nixpkgs#adcli nixpkgs#krb5 nixpkgs#bind -c bash
dig +short SRV _kerberos._tcp.az-group.local @192.168.152.253
dig +short SRV _ldap._tcp.dc._msdcs.az-group.local @192.168.152.253
timedatectl status
# Produce a keytab for that pre-created computer object.
# --host-fqdn redirects adcli from the local machine to the AZ-TC-01
# account; -K writes only to the specified path (does NOT modify the
# local machine's /etc/krb5.keytab).
# Obtain an administrator Kerberos ticket
kinit administrator@AZ-GROUP.LOCAL
klist
# Create the computer account and binary keytab in one step
umask 077
adcli join \
--domain=az-group.local \
--domain-controller=azdc01.az-group.local \
--host-fqdn=AZ-TC-01.az-group.local \
--os-name="NixOS" --os-version="26.05" \
--login-user=administrator \
-K /tmp/AZ-TC-01.keytab
--computer-name=AZ-TC-01 \
--os-name=NixOS \
--os-version=26.05 \
--login-ccache="${KRB5CCNAME:-/tmp/krb5cc_$(id -u)}" \
--host-keytab=/tmp/AZ-TC-01.keytab \
--verbose
# Verify the keytab has expected principals
klist -k /tmp/AZ-TC-01.keytab
# Expected principals:
# AZ-TC-01$@AZ-GROUP
# host/AZ-TC-01.az-group.local@AZ-GROUP
# RestrictedKrbHost/AZ-TC-01.az-group.local@AZ-GROUP
# HOST/AZ-TC-01@AZ-GROUP
# RestrictedKrbHost/AZ-TC-01@AZ-GROUP
# Provision the agenix secret
agenix -e secrets/AZ-TC-01-krb5-keytab.age
# In the editor: paste /tmp/AZ-TC-01.keytab contents, save, exit.
rm /tmp/AZ-TC-01.keytab
# Validate the binary keytab before encryption
klist -k -e /tmp/AZ-TC-01.keytab
# Expected principals include:
# AZ-TC-01$@AZ-GROUP.LOCAL
# host/AZ-TC-01.az-group.local@AZ-GROUP.LOCAL
```
Tip: if you already have an admin TGT (via `kinit administrator@AZ-GROUP`),
you can replace `--login-user=administrator` with
`--login-ccache=${KRB5CCNAME:-/tmp/krb5cc_$(id -u)}` to skip the password
prompt.
**Never paste a binary keytab into an editor.** Encrypt it directly and
verify the round trip before committing:
```bash
agenix -e secrets/AZ-TC-01-krb5-keytab.age < /tmp/AZ-TC-01.keytab
verified_keytab="$(mktemp)"
chmod 0600 "$verified_keytab"
trap 'rm -f "$verified_keytab" /tmp/AZ-TC-01.keytab' EXIT
nix shell nixpkgs#age -c age --decrypt \
-i .secrets/identities/AZ-TC-01.age \
secrets/AZ-TC-01-krb5-keytab.age \
> "$verified_keytab"
nix shell nixpkgs#krb5 -c klist -k -e "$verified_keytab"
rm -f "$verified_keytab" /tmp/AZ-TC-01.keytab
trap - EXIT
```
If the installed `adcli` only exposes the short option for the keytab
path, replace `--host-keytab=/tmp/AZ-TC-01.keytab` with
`-K /tmp/AZ-TC-01.keytab` after confirming via `adcli join --help`.
### Step 2 — Provision NetBird setup key
@@ -101,7 +146,7 @@ In the NetBird UI (`https://netbird.az-group.local`):
3. Copy the key value.
4. `agenix -e secrets/AZ-TC-01-netbird-setupkey.age` → paste the key.
### Step 3 — Provision WiFi client certificate
### Step 3 — Provision WiFi client certificate (`Saturn`, deferred for AZ-TC-01)
In AD CS (`https://certsrv.az-group.local/certsrv`):
@@ -117,6 +162,35 @@ In AD CS (`https://certsrv.az-group.local/certsrv`):
6. `agenix -e secrets/AZ-TC-01-wifi-client-cert.age` → paste the PEM.
### Step 3b — Bootstrap on the temporary `Pluto` PSK network (AZ-TC-01 pilot)
While the `Saturn` EAP-TLS certificate is deferred, AZ-TC-01 connects to
the temporary WPA-Personal network `Pluto` instead
(`az.tc.wifi.mode = "psk"`, see `roles/thin-client/network/wifi.nix`).
Enter the password locally, without putting it in shell history or chat:
```bash
read -rsp 'Pluto WiFi password: ' WIFI_PSK
printf '\n'
printf '%s' "$WIFI_PSK" | nix develop --command agenix -e secrets/AZ-TC-01-wifi-psk.age
unset WIFI_PSK
```
Do not use `echo`, because it may add an unintended trailing newline to
the PSK. Verify the host identity can decrypt the secret without printing
it:
```bash
nix shell nixpkgs#age -c age --decrypt \
-i .secrets/identities/AZ-TC-01.age \
secrets/AZ-TC-01-wifi-psk.age \
| test -s /dev/stdin
```
The password must never be committed in plaintext or sent through chat —
only the encrypted `.age` file is safe to commit.
### Step 4 — Provision RustDesk credentials
```bash
@@ -133,17 +207,28 @@ The shared `rustdesk-psk.age` is one-time setup, reused for all hosts.
### Step 5 — Provision the host
Boot the OptiPlex from a stock Linux ISO (any modern NixOS installer ISO
or Ubuntu live ISO works). From the admin workstation:
or Ubuntu live ISO works). Set a temporary root password on the installer
and ensure its SSH service is running:
```bash
# Bootstrap nixos-anywhere into the booted ISO (via SSH or physical console)
# Then run the install:
nixos-anywhere \
--flake .#AZ-TC-01 \
--disko-config ./roles/thin-client/deployment/disko.nix \
root@<target-ip>
passwd
```
Then run the deployment from the admin workstation:
```bash
# Non-destructive local and remote preflight
nix run .#deploy -- --check AZ-TC-01 root@<target-ip>
# Install after showing the target hardware and confirming disk erasure
nix run .#deploy -- AZ-TC-01 root@<target-ip>
```
The wrapper accepts the installer's new host key in an isolated temporary
file and leaves `~/.ssh/known_hosts` unchanged. SSH may ask for the temporary
root password more than once during preflight and installation; no SSH key
needs to be provisioned on the installer.
The host will:
1. Partition the disk via disko (BTRFS layout).
@@ -152,16 +237,27 @@ The host will:
4. On first boot: agenix decrypts secrets, sssd starts with keytab,
NetBird enrolls via setup key, WiFi connects via EAP-TLS.
### Step 6 — Capture the host's SSH host key
The wrapper refuses to install if the selected host does not evaluate, the
configured target disk does not exist, a required secret is empty, or the
host age identity cannot decrypt an enabled feature's secret.
After first boot:
### Post-boot AD and WiFi checks
After first boot, run this operator checklist to confirm the pilot came
up healthy:
```bash
ssh-keyscan -t ed25519 AZ-TC-01.netbird | awk '{print $2 " " $3}'
nmcli --fields NAME,TYPE,DEVICE connection show --active
resolvectl query azdc01.az-group.local adpdc01.az-group.local
systemctl --no-pager --full status sssd
sssctl domain-status az-group.local
getent passwd '<known-ad-user>'
id '<known-ad-user>'
```
Update `secrets.nix` with the real `AZ-TC-01` SSH key value (replacing
the `PLACEHOLDER` line). Rebuild and redeploy.
Replace `<known-ad-user>` with a real non-administrator test account.
Test offline login (disconnect network, log in from SSSD's credential
cache) only after one successful online login with that account.
## Option reference
@@ -173,6 +269,7 @@ All tunable parameters live under `az.tc.*`:
| `az.tc.hardwareClass` | `generic-x86_64-uefi` | One of `dell-optiplex-micro` or `generic-x86_64-uefi` |
| `az.tc.site` | `default` | Site identifier (informational) |
| `az.tc.ad.ou` | `OU=ThinClients,DC=az-group,DC=local` | AD Organizational Unit for computer objects |
| `az.tc.wifi.mode` | `eap-tls` | WiFi authentication mode: `psk` (temporary WPA-Personal) or `eap-tls` |
| `az.tc.wifi.ssid` | `AZ-CORP` | Corp WiFi SSID |
| `az.tc.wifi.caCert` | `./assets/corp-wifi-ca.pem` | Corp CA cert (NOT secret) |
| `az.tc.netbird.managementUrl` | `https://netbird.az-group.local:443` | NetBird server URL |
@@ -218,8 +315,8 @@ with `# TODO:` in the respective modules.
- [ ] Real IT-Hotline phone number
- [ ] Real corporate wallpaper asset (replace placeholder SVG)
- [ ] Real corporate logo asset (replace placeholder SVG)
- [ ] Real AD DCs (`az-dc01.az-group.local`, `az-dc02.az-group.local` — currently guessed)
- [ ] Real AD Computer OU DN
- [ ] Real AD Computer OU DN (AZ-TC-01 currently uses the default `CN=Computers` container)
- [ ] Real `Saturn` EAP-TLS certificate for AZ-TC-01 (currently on temporary WPA-Personal `Pluto`)
## Build validation