Wzorzec mechaniczny: sekcje deploy/verify/install/testy wycinane do kb/runbooks/<serwis>-*.md, reszta zostaje dokumentem type: service. Wzajemne `links` w obie strony. Tresc sekcji nietknieta — przenoszone doslownie, dodany wylacznie naglowek H1 nowego runbooka. kb-query, paperless-worker, planner-agent, ha-diag-agent, ollama-piha, narty27, home-assistant, ha-mcp, job-gmail-header-backfill, job-mail-body-ingest. Weryfikacja: dla kazdego pliku multizbior niepustych linii (main + runbook) == oryginal z HEAD. Zero zgubionych, zero dodanych. Recon szacowal 13 splitow service+runbook; faktycznie 2-typowych jest 10, pozostale 5 (paperless, nextcloud, gokapi, fleet-prometheus, deploy-runner) sa 3-typowe i ida osobno jako splity wielotypowe. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
65 lines
1.7 KiB
Markdown
65 lines
1.7 KiB
Markdown
---
|
|
okf: "0.1"
|
|
type: runbook
|
|
visibility: private
|
|
status: active
|
|
updated: 2026-06-11
|
|
links:
|
|
- ../services/ha-diag-agent.md
|
|
---
|
|
|
|
# ha-diag-agent — deployment i testy
|
|
|
|
## First-time deployment
|
|
|
|
See **[DEPLOY.md](DEPLOY.md)** for the full procedure: HA token creation,
|
|
per-host `.env` config, deploy commands, verification steps, 48h shadow-mode
|
|
observation, and rollback.
|
|
|
|
**Shadow mode** (`HA_DIAG_SHADOW_MODE`, default `true` on the control-plane):
|
|
`ha_websocket_dead` events are downgraded to `alert_only` with a `[SHADOW MODE]`
|
|
note instead of queuing an automatic `container_restart`. Set to `false` in
|
|
`/opt/homelab/config/control-plane/.env` on the VPS when ready for live actions.
|
|
|
|
## Deployment
|
|
|
|
```bash
|
|
# 1. Create config on target node
|
|
ssh oskar@<node-ip>
|
|
mkdir -p /opt/homelab/config/ha-diag-agent /var/lib/ha-diag-agent
|
|
cat > /opt/homelab/config/ha-diag-agent/.env << 'EOF'
|
|
HA_URL=http://homeassistant.local:8123 # or http://100.70.180.90:8123 for chelsty-infra
|
|
HA_TOKEN=<long-lived-token>
|
|
NODE_NAME=piha # or chelsty-infra
|
|
LOCATION_TAG=ken # or chelsty
|
|
CHECK_INTERVAL=60
|
|
EOF
|
|
|
|
# 2. Deploy
|
|
scripts/deploy/deploy.sh --service ha-diag-agent
|
|
|
|
# 3. Verify
|
|
docker ps --filter name=ha-diag-agent
|
|
docker exec ha-diag-agent python -c "import urllib.request; print(urllib.request.urlopen('http://localhost:8087/health', timeout=5).read().decode())"
|
|
```
|
|
|
|
### chelsty-infra note
|
|
|
|
`chelsty-infra` runs docker-compose v1 (1.29.2). Use `docker-compose` (hyphenated):
|
|
```bash
|
|
docker-compose -f docker-compose.yml up -d --build
|
|
```
|
|
|
|
### HA long-lived token
|
|
|
|
In HA UI: Profile → Long-Lived Access Tokens → Create token.
|
|
|
|
## Running Tests
|
|
|
|
```bash
|
|
cd services/ha-diag-agent
|
|
pip install -e ".[dev]"
|
|
pytest tests/ -v
|
|
```
|
|
|