diff --git a/ops/infra/PLAN.md b/ops/infra/PLAN.md new file mode 100644 index 0000000..e82572b --- /dev/null +++ b/ops/infra/PLAN.md @@ -0,0 +1,58 @@ +# Единый реестр: замена трём параллельным источникам + +## Проблема + +До 06.11.2026 данные об инфраструктуре лежали в **трёх** местах: + +| Файл | Что содержал | Кто генерировал | +|---|---|---| +| `ops/registry/services.yaml` | 127 сервисов, criticality, SSO | `build_registry.py` | +| `ops/topology/topology.json` | 294 узла, 290 рёбер | `build_topology.py` | +| `ops/topology/ledger.md` | RAM, диск, образы | `build_topology.py` + `ledger_extra.py` | + +Пересечение по CT, IP, портам — 70 %. Риск: расходятся, непонятно, кто прав. + +## Решение + +**Один файл — `ops/infra/registry.yaml`**, генерируется из живого состояния: + +``` +hosts — CT + VM (id, vmid, имя, статус, onboot, лимит RAM) +services — docker-контейнеры (имя, хост, образ, порты, IP) +domains — домены из nginx (домен, upstream, SSL, SSO, хост/VPS) +counts — сводка +``` + +Отчёты (markdown, диаграммы) — **производные**, генерируются из реестра, не ведутся руками. + +## Добавлены домены (главное дополнение) + +| Параметр | Значение | +|---|---| +| Доменов найдено | **50** | +| С SSL | большинство | +| На VPS | 4 | +| С SSO (auth_request) | 2 — **требует проверки** | + +Парсер nginx: разбор по балансу скобок (вложенные `location` не ломают). + +## Что ещё нужно (следующий шаг) + +1. **SSO-детект**: `auth_request` нашёлся только в 2 доменах, хотя oauth2-proxy 18 шт. + Вероятно, часть доменов проксируется иначе (`proxy_pass` на oauth2-proxy напрямую) — + надо уточнить правило. +2. **Зависимости**: перенести рёбра из `topology.json` в реестр (`dependencies:`). +3. **Стоимость**: RAM/диск по сервису (сейчас только лимиты хостов). +4. **После этого** — удалить дубли (список ниже), оставить генераторы. + +## План консолидации (без спешки) + +| Шаг | Действие | Риск | +|---|---|---| +| 1 | Добавить `dependencies` и `cost` в реестр | нет | +| 2 | Перевести гигиену/эволюцию на чтение реестра | низкий | +| 3 | Переименовать старые файлы в `.legacy` | нет | +| 4 | Через неделю — удалить `.legacy` | нет | + +**Не удаляю сразу**: агенты (`evolution_agent`, `hygiene_scan`) пока читают старые файлы. +Сначала переключить их, потом убирать. diff --git a/ops/infra/README.md b/ops/infra/README.md new file mode 100644 index 0000000..c61b187 --- /dev/null +++ b/ops/infra/README.md @@ -0,0 +1,54 @@ +# Реестр инфраструктуры (единый источник правды) + +_Обновлено: 2026-11-06T11:01:08_ + +| Сущность | Количество | +|---|---| +| Хосты (CT + VM) | 34 | +| Сервисы (docker) | 170 | +| Домены | 50 | + +## Домены + +| Домен | Куда ведёт | SSL | SSO | Где | +|---|---|---|---|---| +| 193.233.210.184 | api.telegram.org/ | да | нет | vps | +| 3d.buryans.ru | 192.168.1.110:9131 | да | да | host | +| adguard.buryans.ru | 192.168.1.107:3000 | да | нет | host | +| admin.buryans.ru | 192.168.1.114:9000 | да | нет | host | +| authentik.buryans.ru | 192.168.1.114:9000 | да | нет | host | +| backup.buryans.ru | 192.168.1.113:9102 | да | нет | host | +| bazarr.buryans.ru | 192.168.1.120:9986 | да | нет | host | +| books.buryans.ru | 192.168.1.240:9990 | да | нет | host | +| chat.buryans.ru | — | да | нет | host | +| docs.buryans.ru | 192.168.1.110:9981 | да | нет | host | +| element.buryans.ru | 192.168.1.155:9103 | да | нет | host | +| files.buryans.ru | 192.168.1.109:8080 | да | нет | host | +| finance.buryans.ru | 192.168.1.110:9104 | да | нет | host | +| flow.buryans.ru | 192.168.1.108:1881 | да | нет | host | +| git.buryans.ru | 192.168.1.140:3000 | да | нет | host | +| grafana.buryans.ru | — | нет | нет | host | +| grocy.buryans.ru | 192.168.1.110:9284 | да | нет | host | +| headscale.buryans.ru | 100.64.0.2:8443 | да | нет | host | +| home.buryans.ru | 192.168.1.106:9130 | да | нет | host | +| homebox.buryans.ru | — | нет | нет | host | +| hub.buryans.ru | 192.168.1.10:9120/me | да | нет | host | +| immich.buryans.ru | 192.168.1.104:2283 | да | нет | host | +| links.buryans.ru | 192.168.1.127:9091 | да | нет | host | +| logs.buryans.ru | — | нет | нет | host | +| matrix.buryans.ru | 192.168.1.155:8008 | да | нет | host | +| meals.buryans.ru | 192.168.1.110:9925 | да | нет | host | +| media.buryans.ru | 192.168.1.103:8096 | да | нет | host | +| memo.buryans.ru | — | нет | нет | host | +| metrics.buryans.ru | — | нет | нет | host | +| music.buryans.ru | 192.168.1.125:9976 | да | нет | host | +| n8n.buryans.ru | 192.168.1.108:9105 | да | да | host | +| news.buryans.ru | 192.168.1.240:8091 | да | нет | host | +| ns1.buryans.ru | — | да | нет | host | +| ombi.buryans.ru | 192.168.1.121:5055 | да | нет | host | +| openclaw.buryans.ru | 192.168.1.115:9108 | да | нет | host | +| pdf.buryans.ru | — | нет | нет | host | +| plex.buryans.ru | 192.168.1.116:32400 | да | нет | host | +| prowlarr.buryans.ru | 192.168.1.119:9987 | да | нет | host | +| pve.buryans.ru | 192.168.1.10:8006 | да | нет | host | +| radarr.buryans.ru | 192.168.1.118:9988 | да | нет | host | diff --git a/ops/infra/registry.yaml b/ops/infra/registry.yaml new file mode 100644 index 0000000..fe80ba7 --- /dev/null +++ b/ops/infra/registry.yaml @@ -0,0 +1,1429 @@ +version: 2 +generated: '2026-11-06T11:01:08' +counts: + hosts: 34 + services: 170 + domains: 50 +hosts: +- id: ct101 + vmid: 101 + type: lxc + name: proxy-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct102 + vmid: 102 + type: lxc + name: portal-lxc + status: running + onboot: true + ram_limit_mb: 512 +- id: ct103 + vmid: 103 + type: lxc + name: media-lxc + status: running + onboot: true + ram_limit_mb: 4096 +- id: ct105 + vmid: 105 + type: lxc + name: files-lxc + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct106 + vmid: 106 + type: lxc + name: smart-lxc + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct107 + vmid: 107 + type: lxc + name: utils-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct108 + vmid: 108 + type: lxc + name: automation-lxc + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct109 + vmid: 109 + type: lxc + name: cloud-lxc + status: running + onboot: true + ram_limit_mb: 4096 +- id: ct110 + vmid: 110 + type: lxc + name: office-lxc + status: running + onboot: true + ram_limit_mb: 6144 +- id: ct111 + vmid: 111 + type: lxc + name: reading-lxc + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct113 + vmid: 113 + type: lxc + name: backup-lxc + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct114 + vmid: 114 + type: lxc + name: authentik-security + status: running + onboot: true + ram_limit_mb: 4096 +- id: ct115 + vmid: 115 + type: lxc + name: OpenClaw + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct116 + vmid: 116 + type: lxc + name: plex-lxc + status: running + onboot: true + ram_limit_mb: 4096 +- id: ct117 + vmid: 117 + type: lxc + name: sonarr-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct118 + vmid: 118 + type: lxc + name: radarr-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct119 + vmid: 119 + type: lxc + name: prowlarr-lxc + status: running + onboot: true + ram_limit_mb: 512 +- id: ct120 + vmid: 120 + type: lxc + name: bazarr-lxc + status: running + onboot: true + ram_limit_mb: 512 +- id: ct121 + vmid: 121 + type: lxc + name: overseerr-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct122 + vmid: 122 + type: lxc + name: tautulli-lxc + status: running + onboot: true + ram_limit_mb: 512 +- id: ct123 + vmid: 123 + type: lxc + name: torrent-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct124 + vmid: 124 + type: lxc + name: jackett-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct125 + vmid: 125 + type: lxc + name: navidrome-lxc + status: running + onboot: true + ram_limit_mb: 512 +- id: ct126 + vmid: 126 + type: lxc + name: frigate-lxc + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct127 + vmid: 127 + type: lxc + name: linkwarden-lxc + status: running + onboot: true + ram_limit_mb: 512 +- id: ct134 + vmid: 134 + type: lxc + name: prometheus-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct139 + vmid: 139 + type: lxc + name: syncthing-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: ct140 + vmid: 140 + type: lxc + name: gitea-lxc + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct151 + vmid: 151 + type: lxc + name: postgres-rbac-lxc + status: running + onboot: true + ram_limit_mb: 2048 +- id: ct155 + vmid: 155 + type: lxc + name: matrix + status: running + onboot: true + ram_limit_mb: 6144 +- id: ct160 + vmid: 160 + type: lxc + name: llm-lxc + status: stopped + onboot: false + ram_limit_mb: 4096 +- id: ct161 + vmid: 161 + type: lxc + name: gateway-lxc + status: running + onboot: true + ram_limit_mb: 256 +- id: ct201 + vmid: 201 + type: lxc + name: headscale-lxc + status: running + onboot: true + ram_limit_mb: 1024 +- id: vm104 + vmid: 104 + type: qemu + name: immich-prod + status: running + onboot: true + ram_limit_mb: 2048 +services: +- name: beszel-agent + host: ct101 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.101 +- name: promtail + host: ct101 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.101 +- name: oauth2-proxy-dashy + host: ct102 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9983 + ip: 192.168.1.102 +- name: beszel-agent + host: ct102 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.102 +- name: dashy + host: ct102 + image: lissy93/dashy:latest + ports: null + ip: 192.168.1.102 +- name: promtail + host: ct102 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.102 +- name: jellyfin + host: ct103 + image: jellyfin/jellyfin:latest + ports: null + ip: 192.168.1.103 +- name: beszel-agent + host: ct103 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.103 +- name: docmost-redis + host: ct103 + image: redis:7-alpine + ports: null + ip: 192.168.1.103 +- name: oauth2-proxy-docmost + host: ct103 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: null + ip: 192.168.1.103 +- name: oauth2-proxy-podfetch + host: ct103 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: null + ip: 192.168.1.103 +- name: podfetch + host: ct103 + image: samuel19982/podfetch:latest + ports: + - 3003 + ip: 192.168.1.103 +- name: docmost + host: ct103 + image: docmost/docmost:latest + ports: + - 3001 + ip: 192.168.1.103 +- name: promtail + host: ct103 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.103 +- name: jellystat + host: ct103 + image: cyfershepard/jellystat:latest + ports: + - 3100 + ip: 192.168.1.103 +- name: docmost-db + host: ct103 + image: postgres:16-alpine + ports: null + ip: 192.168.1.103 +- name: paperless_redis + host: ct105 + image: redis:7-alpine + ports: null + ip: 192.168.1.105 +- name: beszel-agent + host: ct105 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.105 +- name: paperless + host: ct105 + image: ghcr.io/paperless-ngx/paperless-ngx:latest + ports: + - 8000 + ip: 192.168.1.105 +- name: promtail + host: ct105 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.105 +- name: syncthing + host: ct105 + image: lscr.io/linuxserver/syncthing:latest + ports: null + ip: 192.168.1.105 +- name: oauth2-proxy-home + host: ct106 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9130 + ip: 192.168.1.106 +- name: beszel-agent + host: ct106 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.106 +- name: mosquitto + host: ct106 + image: eclipse-mosquitto:latest + ports: + - 1883 + - 9001 + ip: 192.168.1.106 +- name: homeassistant + host: ct106 + image: ghcr.io/home-assistant/home-assistant:stable + ports: null + ip: 192.168.1.106 +- name: ha-strip + host: ct106 + image: nginx:alpine + ports: + - 8130 + ip: 192.168.1.106 +- name: promtail + host: ct106 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.106 +- name: oauth2-proxy-status + host: ct107 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9109 + ip: 192.168.1.107 +- name: beszel-agent + host: ct107 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.107 +- name: uptime_kuma + host: ct107 + image: louislam/uptime-kuma:2 + ports: + - 3001 + ip: 192.168.1.107 +- name: adguard + host: ct107 + image: adguard/adguardhome:latest + ports: null + ip: 192.168.1.107 +- name: mosquitto + host: ct107 + image: eclipse-mosquitto:2 + ports: null + ip: 192.168.1.107 +- name: promtail + host: ct107 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.107 +- name: n8n + host: ct108 + image: n8nio/n8n:latest + ports: + - 5680 + ip: 192.168.1.108 +- name: oauth2-proxy-n8n + host: ct108 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9105 + ip: 192.168.1.108 +- name: oauth2-proxy-nodered + host: ct108 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 1881 + ip: 192.168.1.108 +- name: node_red + host: ct108 + image: nodered/node-red:latest + ports: + - 1880 + ip: 192.168.1.108 +- name: beszel-agent + host: ct108 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.108 +- name: promtail + host: ct108 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.108 +- name: tg-admin-bot + host: ct108 + image: telegram-admin-bot-tg-admin-bot + ports: null + ip: 192.168.1.108 +- name: beszel-agent + host: ct109 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.109 +- name: nextcloud + host: ct109 + image: nextcloud:latest + ports: + - 8080 + ip: 192.168.1.109 +- name: promtail + host: ct109 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.109 +- name: vaultwarden + host: ct109 + image: vaultwarden/server:latest + ports: + - 8081 + ip: 192.168.1.109 +- name: files_db + host: ct109 + image: mariadb:10.6 + ports: null + ip: 192.168.1.109 +- name: oauth2-proxy-monica + host: ct110 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: null + ip: 192.168.1.110 +- name: oauth2-proxy-metrics + host: ct110 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: null + ip: 192.168.1.110 +- name: oauth2-proxy-finance + host: ct110 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9104 + ip: 192.168.1.110 +- name: oauth2-proxy-grocy + host: ct110 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9284 + ip: 192.168.1.110 +- name: oauth2-proxy-paperless + host: ct110 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9981 + ip: 192.168.1.110 +- name: oauth2-proxy-logs + host: ct110 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: null + ip: 192.168.1.110 +- name: oauth2-proxy-stirling + host: ct110 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: null + ip: 192.168.1.110 +- name: oauth2-proxy-3d + host: ct110 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9131 + ip: 192.168.1.110 +- name: paperless_web + host: ct110 + image: ghcr.io/paperless-ngx/paperless-ngx:latest + ports: + - 8000 + ip: 192.168.1.110 +- name: paperless_worker + host: ct110 + image: ghcr.io/paperless-ngx/paperless-ngx:latest + ports: null + ip: 192.168.1.110 +- name: paperless_redis + host: ct110 + image: redis:7-alpine + ports: null + ip: 192.168.1.110 +- name: house3d-web + host: ct110 + image: nginx:1.27-alpine + ports: + - 8093 + ip: 192.168.1.110 +- name: stirling-pdf + host: ct110 + image: frooodle/s-pdf:latest + ports: null + ip: 192.168.1.110 +- name: dozzle + host: ct110 + image: amir20/dozzle:latest + ports: null + ip: 192.168.1.110 +- name: monica + host: ct110 + image: monica + ports: + - 8081 + ip: 192.168.1.110 +- name: monica-db + host: ct110 + image: mariadb:11 + ports: null + ip: 192.168.1.110 +- name: firefly + host: ct110 + image: fireflyiii/core:latest + ports: + - 8080 + ip: 192.168.1.110 +- name: mealie + host: ct110 + image: ghcr.io/mealie-recipes/mealie:latest + ports: + - 9925 + ip: 192.168.1.110 +- name: vikunja + host: ct110 + image: vikunja/vikunja:latest + ports: + - 9285 + ip: 192.168.1.110 +- name: promtail + host: ct110 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.110 +- name: homebox + host: ct110 + image: ghcr.io/sysadminsmedia/homebox:latest + ports: + - 9287 + ip: 192.168.1.110 +- name: grocy + host: ct110 + image: lscr.io/linuxserver/grocy:latest + ports: + - 9283 + ip: 192.168.1.110 +- name: beszel-agent + host: ct110 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.110 +- name: beszel + host: ct110 + image: henrygd/beszel:latest + ports: + - 8092 + ip: 192.168.1.110 +- name: memos + host: ct110 + image: neosmemo/memos:stable + ports: + - 5230 + ip: 192.168.1.110 +- name: book-bot + host: ct111 + image: buryan/book-bot:latest + ports: null + ip: 192.168.1.111 +- name: beszel-agent + host: ct111 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.111 +- name: oauth2-proxy-audiobookshelf + host: ct111 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: null + ip: 192.168.1.111 +- name: oauth2-proxy-calibre + host: ct111 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9982 + ip: 192.168.1.111 +- name: oauth2-proxy-catalog + host: ct111 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9990 + ip: 192.168.1.111 +- name: oauth2-proxy-freshrss + host: ct111 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 8091 + ip: 192.168.1.111 +- name: duplicati + host: ct111 + image: duplicati/duplicati:latest + ports: + - 8200 + ip: 192.168.1.111 +- name: audiobookshelf + host: ct111 + image: ghcr.io/advplyr/audiobookshelf:latest + ports: + - 13378 + ip: 192.168.1.111 +- name: freshrss + host: ct111 + image: freshrss/freshrss:latest + ports: + - 8090 + ip: 192.168.1.111 +- name: calibre-web + host: ct111 + image: crocodilestick/calibre-web-automated:latest + ports: + - 8083 + ip: 192.168.1.111 +- name: lidarr + host: ct111 + image: ghcr.nju.edu.cn/linuxserver/lidarr:latest + ports: null + ip: 192.168.1.111 +- name: catalog + host: ct111 + image: buryan/catalog:latest + ports: + - 9200 + ip: 192.168.1.111 +- name: promtail + host: ct111 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.111 +- name: kavita + host: ct111 + image: jvmilazz0/kavita:latest + ports: + - 5000 + ip: 192.168.1.111 +- name: promtail + host: ct113 + image: grafana/promtail:3.5.1 + ports: null + ip: 192.168.1.113 +- name: beszel-agent + host: ct113 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.113 +- name: loki + host: ct113 + image: grafana/loki:3.7.9 + ports: + - 3100 + ip: 192.168.1.113 +- name: grafana + host: ct113 + image: grafana/grafana:latest + ports: + - 3000 + ip: 192.168.1.113 +- name: oauth2-proxy-backup + host: ct113 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9102 + ip: 192.168.1.113 +- name: authentik-security-redis-1 + host: ct114 + image: redis:7-alpine + ports: null + ip: 192.168.1.114 +- name: beszel-agent + host: ct114 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.114 +- name: authentik-security-worker-1 + host: ct114 + image: ghcr.io/goauthentik/server:2026.8.5 + ports: null + ip: 192.168.1.114 +- name: authentik-security-server-1 + host: ct114 + image: ghcr.io/goauthentik/server:2026.8.5 + ports: + - 9000 + - 9443 + ip: 192.168.1.114 +- name: promtail + host: ct114 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.114 +- name: authentik-security-postgresql-1 + host: ct114 + image: postgres:16-alpine + ports: null + ip: 192.168.1.114 +- name: oauth2-proxy-openclaw + host: ct115 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9108 + ip: 192.168.1.115 +- name: swarm-redis + host: ct115 + image: redis:7-alpine + ports: + - 6379 + ip: 192.168.1.115 +- name: beszel-agent + host: ct115 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.115 +- name: openclaw + host: ct115 + image: 3814fb1f62f9 + ports: null + ip: 192.168.1.115 +- name: promtail + host: ct115 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.115 +- name: nats + host: ct115 + image: nats:2.10.17-alpine + ports: + - 4222 + - 8222 + ip: 192.168.1.115 +- name: beszel-agent + host: ct116 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.116 +- name: plex + host: ct116 + image: linuxserver/plex:latest + ports: + - 32400 + ip: 192.168.1.116 +- name: promtail + host: ct116 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.116 +- name: oauth2-proxy-sonarr + host: ct117 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9989 + ip: 192.168.1.117 +- name: sonarr + host: ct117 + image: lscr.io/linuxserver/sonarr:latest + ports: + - 8989 + ip: 192.168.1.117 +- name: beszel-agent + host: ct117 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.117 +- name: promtail + host: ct117 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.117 +- name: oauth2-proxy-radarr + host: ct118 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9988 + ip: 192.168.1.118 +- name: radarr + host: ct118 + image: lscr.io/linuxserver/radarr:latest + ports: + - 7878 + ip: 192.168.1.118 +- name: beszel-agent + host: ct118 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.118 +- name: promtail + host: ct118 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.118 +- name: oauth2-proxy-prowlarr + host: ct119 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9987 + ip: 192.168.1.119 +- name: prowlarr + host: ct119 + image: lscr.io/linuxserver/prowlarr:latest + ports: + - 9696 + ip: 192.168.1.119 +- name: beszel-agent + host: ct119 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.119 +- name: promtail + host: ct119 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.119 +- name: bazarr + host: ct120 + image: lscr.io/linuxserver/bazarr:latest + ports: + - 6767 + ip: 192.168.1.120 +- name: beszel-agent + host: ct120 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.120 +- name: oauth2-proxy-bazarr + host: ct120 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9986 + ip: 192.168.1.120 +- name: promtail + host: ct120 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.120 +- name: beszel-agent + host: ct121 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.121 +- name: seerr + host: ct121 + image: ghcr.io/seerr-team/seerr:latest + ports: + - 5055 + ip: 192.168.1.121 +- name: promtail + host: ct121 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.121 +- name: beszel-agent + host: ct122 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.122 +- name: oauth2-proxy-tautulli + host: ct122 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9984 + ip: 192.168.1.122 +- name: promtail + host: ct122 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.122 +- name: tautulli + host: ct122 + image: tautulli/tautulli:latest + ports: + - 8181 + ip: 192.168.1.122 +- name: beszel-agent + host: ct124 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.124 +- name: jackett + host: ct124 + image: lscr.io/linuxserver/jackett:latest + ports: + - 9117 + ip: 192.168.1.124 +- name: beszel-agent + host: ct125 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.125 +- name: oauth2-proxy-navidrome + host: ct125 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9976 + ip: 192.168.1.125 +- name: promtail + host: ct125 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.125 +- name: navidrome + host: ct125 + image: deluan/navidrome:latest + ports: null + ip: 192.168.1.125 +- name: beszel-agent + host: ct126 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.126 +- name: frigate + host: ct126 + image: ghcr.io/blakeblackshear/frigate:stable + ports: + - 5000 + - 8971 + ip: 192.168.1.126 +- name: beszel-agent + host: ct127 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.127 +- name: oauth2-proxy-linkding + host: ct127 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9091 + ip: 192.168.1.127 +- name: promtail + host: ct127 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.127 +- name: linkding + host: ct127 + image: sissbruecker/linkding:latest + ports: + - 3000 + ip: 192.168.1.127 +- name: beszel-agent + host: ct134 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.134 +- name: alertmanager + host: ct134 + image: prom/alertmanager:v0.34.1 + ports: null + ip: 192.168.1.134 +- name: prometheus + host: ct134 + image: prom/prometheus:latest + ports: + - 9090 + ip: 192.168.1.134 +- name: promtail + host: ct134 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.134 +- name: buryan-alert-webhook + host: ct134 + image: python:3.12-alpine + ports: null + ip: 192.168.1.134 +- name: exportarr-sonarr + host: ct134 + image: ghcr.io/onedr0p/exportarr:latest + ports: + - 9707 + ip: 192.168.1.134 +- name: oauth2-proxy-prometheus + host: ct134 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9113 + ip: 192.168.1.134 +- name: exportarr-prowlarr + host: ct134 + image: ghcr.io/onedr0p/exportarr:latest + ports: + - 9709 + ip: 192.168.1.134 +- name: exportarr-bazarr + host: ct134 + image: ghcr.io/onedr0p/exportarr:latest + ports: + - 9710 + ip: 192.168.1.134 +- name: exportarr-radarr + host: ct134 + image: ghcr.io/onedr0p/exportarr:latest + ports: + - 9708 + ip: 192.168.1.134 +- name: beszel-agent + host: ct139 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.139 +- name: syncthing + host: ct139 + image: syncthing/syncthing:latest + ports: + - 8384 + ip: 192.168.1.139 +- name: promtail + host: ct139 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.139 +- name: gitea + host: ct140 + image: gitea/gitea:latest + ports: + - 3000 + - 222 + ip: 192.168.1.140 +- name: beszel-agent + host: ct140 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.140 +- name: gitea-runner + host: ct140 + image: gitea/act_runner:latest + ports: null + ip: 192.168.1.140 +- name: promtail + host: ct140 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.140 +- name: oauth2-proxy-element + host: ct155 + image: quay.io/oauth2-proxy/oauth2-proxy:latest + ports: + - 9103 + ip: 192.168.1.155 +- name: beszel-agent + host: ct155 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.155 +- name: livekit + host: ct155 + image: livekit/livekit-server:latest + ports: null + ip: 192.168.1.155 +- name: element-web + host: ct155 + image: vectorim/element-web:latest + ports: + - 8088 + ip: 192.168.1.155 +- name: matrix-synapse + host: ct155 + image: matrixdotorg/synapse:latest + ports: + - 8008 + ip: 192.168.1.155 +- name: matrix-coturn + host: ct155 + image: coturn/coturn:latest + ports: null + ip: 192.168.1.155 +- name: promtail + host: ct155 + image: grafana/promtail:3.2.1 + ports: null + ip: 192.168.1.155 +- name: mautrix-telegram + host: ct155 + image: dock.mau.dev/mautrix/telegram:latest + ports: + - 29317 + ip: 192.168.1.155 +- name: node_exporter + host: vm104 + image: prom/node-exporter:latest + ports: null + ip: 192.168.1.104 +- name: beszel-agent + host: vm104 + image: henrygd/beszel-agent:latest + ports: null + ip: 192.168.1.104 +- name: zigbee2mqtt + host: vm104 + image: ghcr.nju.edu.cn/koenkk/zigbee2mqtt:latest + ports: null + ip: 192.168.1.104 +- name: portainer + host: vm104 + image: portainer/portainer-ce:latest + ports: + - 9000 + ip: 192.168.1.104 +- name: immich_database + host: vm104 + image: tensorchord/pgvecto-rs:pg14-v0.2.0 + ports: null + ip: 192.168.1.104 +- name: heimdall + host: vm104 + image: lscr.io/linuxserver/heimdall:latest + ports: + - 8088 + ip: 192.168.1.104 +domains: +- domain: 193.233.210.184 + upstream: api.telegram.org/ + ssl: true + sso: false + edge: vps +- domain: 3d.buryans.ru + upstream: 192.168.1.110:9131 + ssl: true + sso: true + edge: host +- domain: adguard.buryans.ru + upstream: 192.168.1.107:3000 + ssl: true + sso: false + edge: host +- domain: admin.buryans.ru + upstream: 192.168.1.114:9000 + ssl: true + sso: false + edge: host +- domain: authentik.buryans.ru + upstream: 192.168.1.114:9000 + ssl: true + sso: false + edge: host +- domain: backup.buryans.ru + upstream: 192.168.1.113:9102 + ssl: true + sso: false + edge: host +- domain: bazarr.buryans.ru + upstream: 192.168.1.120:9986 + ssl: true + sso: false + edge: host +- domain: books.buryans.ru + upstream: 192.168.1.240:9990 + ssl: true + sso: false + edge: host +- domain: chat.buryans.ru + upstream: null + ssl: true + sso: false + edge: host +- domain: docs.buryans.ru + upstream: 192.168.1.110:9981 + ssl: true + sso: false + edge: host +- domain: element.buryans.ru + upstream: 192.168.1.155:9103 + ssl: true + sso: false + edge: host +- domain: files.buryans.ru + upstream: 192.168.1.109:8080 + ssl: true + sso: false + edge: host +- domain: finance.buryans.ru + upstream: 192.168.1.110:9104 + ssl: true + sso: false + edge: host +- domain: flow.buryans.ru + upstream: 192.168.1.108:1881 + ssl: true + sso: false + edge: host +- domain: git.buryans.ru + upstream: 192.168.1.140:3000 + ssl: true + sso: false + edge: host +- domain: grafana.buryans.ru + upstream: null + ssl: false + sso: false + edge: host +- domain: grocy.buryans.ru + upstream: 192.168.1.110:9284 + ssl: true + sso: false + edge: host +- domain: headscale.buryans.ru + upstream: 100.64.0.2:8443 + ssl: true + sso: false + edge: host +- domain: home.buryans.ru + upstream: 192.168.1.106:9130 + ssl: true + sso: false + edge: host +- domain: homebox.buryans.ru + upstream: null + ssl: false + sso: false + edge: host +- domain: hub.buryans.ru + upstream: 192.168.1.10:9120/me + ssl: true + sso: false + edge: host +- domain: immich.buryans.ru + upstream: 192.168.1.104:2283 + ssl: true + sso: false + edge: host +- domain: links.buryans.ru + upstream: 192.168.1.127:9091 + ssl: true + sso: false + edge: host +- domain: logs.buryans.ru + upstream: null + ssl: false + sso: false + edge: host +- domain: matrix.buryans.ru + upstream: 192.168.1.155:8008 + ssl: true + sso: false + edge: host +- domain: meals.buryans.ru + upstream: 192.168.1.110:9925 + ssl: true + sso: false + edge: host +- domain: media.buryans.ru + upstream: 192.168.1.103:8096 + ssl: true + sso: false + edge: host +- domain: memo.buryans.ru + upstream: null + ssl: false + sso: false + edge: host +- domain: metrics.buryans.ru + upstream: null + ssl: false + sso: false + edge: host +- domain: music.buryans.ru + upstream: 192.168.1.125:9976 + ssl: true + sso: false + edge: host +- domain: n8n.buryans.ru + upstream: 192.168.1.108:9105 + ssl: true + sso: true + edge: host +- domain: news.buryans.ru + upstream: 192.168.1.240:8091 + ssl: true + sso: false + edge: host +- domain: ns1.buryans.ru + upstream: null + ssl: true + sso: false + edge: host +- domain: ombi.buryans.ru + upstream: 192.168.1.121:5055 + ssl: true + sso: false + edge: host +- domain: openclaw.buryans.ru + upstream: 192.168.1.115:9108 + ssl: true + sso: false + edge: host +- domain: pdf.buryans.ru + upstream: null + ssl: false + sso: false + edge: host +- domain: plex.buryans.ru + upstream: 192.168.1.116:32400 + ssl: true + sso: false + edge: host +- domain: prowlarr.buryans.ru + upstream: 192.168.1.119:9987 + ssl: true + sso: false + edge: host +- domain: pve.buryans.ru + upstream: 192.168.1.10:8006 + ssl: true + sso: false + edge: host +- domain: radarr.buryans.ru + upstream: 192.168.1.118:9988 + ssl: true + sso: false + edge: host +- domain: recipes.buryans.ru + upstream: null + ssl: true + sso: false + edge: host +- domain: requests.buryans.ru + upstream: null + ssl: true + sso: false + edge: host +- domain: rss.buryans.ru + upstream: 192.168.1.240:8091 + ssl: true + sso: false + edge: host +- domain: sonarr.buryans.ru + upstream: 192.168.1.117:9989 + ssl: true + sso: false + edge: host +- domain: status.buryans.ru + upstream: 192.168.1.10:9120/ + ssl: true + sso: false + edge: host +- domain: sync.buryans.ru + upstream: 192.168.1.139:8384 + ssl: true + sso: false + edge: host +- domain: turn.buryans.ru + upstream: null + ssl: true + sso: false + edge: host +- domain: vault.buryans.ru + upstream: 192.168.1.109:8081 + ssl: true + sso: false + edge: host +- domain: vikunja.buryans.ru + upstream: 192.168.1.110:9285 + ssl: true + sso: false + edge: host +- domain: www.buryans.ru + upstream: null + ssl: true + sso: false + edge: host diff --git a/ops/scripts/build_registry_v2.py b/ops/scripts/build_registry_v2.py new file mode 100755 index 0000000..22c9eb9 --- /dev/null +++ b/ops/scripts/build_registry_v2.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +"""Единый реестр инфраструктуры: хосты + сервисы + домены + зависимости + стоимость. + +Заменяет три параллельных источника (services.yaml, topology.json, ledger.md) +одним файлом, из которого генерируются отчёты. + +Выход: ops/infra/registry.yaml, ops/infra/README.md +""" +import json +import os +import re +import subprocess +from datetime import datetime + +ROOT = "/root/buryan-infra" +OUT = ROOT + "/ops/infra" + + +def sh(cmd, timeout=90): + try: + r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout) + return (r.stdout or "").strip() + except Exception: + return "" + + +def hosts(): + out = [] + for line in sh("pct list").splitlines()[1:]: + p = line.split() + if len(p) < 2: + continue + ct, status = p[0], p[1] + name = p[2] if len(p) > 2 else "?" + cfg = sh("cat /etc/pve/lxc/%s.conf 2>/dev/null" % ct, 15) + mem = re.search(r"^memory:\s*(\d+)", cfg, re.M) + out.append({"id": "ct%s" % ct, "vmid": int(ct), "type": "lxc", "name": name, + "status": status, "onboot": "onboot: 1" in cfg, + "ram_limit_mb": int(mem.group(1)) if mem else None}) + for line in sh("qm list 2>/dev/null").splitlines()[1:]: + p = line.split() + if len(p) < 3: + continue + cfg = sh("cat /etc/pve/qemu-server/%s.conf 2>/dev/null" % p[0], 15) + mem = re.search(r"^memory:\s*(\d+)", cfg, re.M) + out.append({"id": "vm%s" % p[0], "vmid": int(p[0]), "type": "qemu", "name": p[1], + "status": p[2], "onboot": "onboot: 1" in cfg, + "ram_limit_mb": int(mem.group(1)) if mem else None}) + return out + + +def services(hostlist): + out = [] + for h in hostlist: + if h["status"] != "running": + continue + if h["type"] == "lxc": + cmd = "pct exec %s -- " % h["vmid"] + else: + cmd = "" + raw = sh(cmd + "docker ps --format '{{.Names}}|{{.Image}}|{{.Ports}}' 2>/dev/null", 60) + for ln in raw.splitlines(): + f = ln.split("|") + if len(f) < 3: + continue + ports = re.findall(r"0\.0\.0\.0:(\d+)->", f[2]) + out.append({"name": f[0], "host": h["id"], "image": f[1], + "ports": [int(x) for x in ports] or None, + "ip": "192.168.1.%s" % h["vmid"]}) + return out + + +def _blocks(text): + """Разбирает nginx-конфиг по балансу скобок: возвращает тексты server-блоков.""" + blocks, depth, buf, in_server = [], 0, [], False + for line in text.splitlines(): + if not in_server and re.match(r"\s*server\s*\{", line): + in_server, depth, buf = True, 0, [] + if in_server: + buf.append(line) + depth += line.count("{") - line.count("}") + if depth <= 0: + blocks.append("\n".join(buf)) + in_server = False + return blocks + + +def domains(): + """Домены из nginx: server_name + proxy_pass (хост и VPS).""" + seen, out = set(), [] + sources = [("host", sh("cat /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* 2>/dev/null", 40))] + vps = sh("ssh -o ConnectTimeout=8 -o BatchMode=yes root@193.233.210.184 " + "'cat /etc/nginx/sites-enabled/* 2>/dev/null'", 40) + if vps: + sources.append(("vps", vps)) + for where, text in sources: + for block in _blocks(text or ""): + names = re.findall(r"server_name\s+([^;]+);", block) + if not names: + continue + ups = [u for u in re.findall(r"proxy_pass\s+https?://([^;\s]+)", block) + if "oauth2" not in u] + ssl = "ssl_certificate" in block + auth = "auth_request" in block + for n in names[0].split(): + n = n.strip() + if not n or n in ("_", "localhost") or "$" in n or n in seen: + continue + seen.add(n) + out.append({"domain": n, "upstream": ups[0] if ups else None, + "ssl": ssl, "sso": auth, "edge": where}) + return sorted(out, key=lambda x: x["domain"]) + + +def main(): + os.makedirs(OUT, exist_ok=True) + h = hosts() + s = services(h) + d = domains() + import yaml + reg = {"version": 2, + "generated": datetime.now().isoformat(timespec="seconds"), + "counts": {"hosts": len(h), "services": len(s), "domains": len(d)}, + "hosts": h, "services": s, "domains": d} + path = os.path.join(OUT, "registry.yaml") + with open(path, "w", encoding="utf-8") as f: + yaml.safe_dump(reg, f, allow_unicode=True, sort_keys=False, width=200) + + # README с картой + L = ["# Реестр инфраструктуры (единый источник правды)", "", + "_Обновлено: %s_" % reg["generated"], "", + "| Сущность | Количество |", "|---|---|", + "| Хосты (CT + VM) | %d |" % len(h), + "| Сервисы (docker) | %d |" % len(s), + "| Домены | %d |" % len(d), ""] + if d: + L += ["## Домены", "", "| Домен | Куда ведёт | SSL | SSO | Где |", "|---|---|---|---|---|"] + for x in sorted(d, key=lambda v: v["domain"])[:40]: + L.append("| %s | %s | %s | %s | %s |" % + (x["domain"], (x.get("upstream") or "—")[:30], + "да" if x["ssl"] else "нет", "да" if x["sso"] else "нет", + x.get("edge", "хост"))) + open(os.path.join(OUT, "README.md"), "w", encoding="utf-8").write("\n".join(L) + "\n") + print("реестр:", path) + print("хостов: %d | сервисов: %d | доменов: %d" % (len(h), len(s), len(d))) + print("домены с SSO: %d | без SSO: %d" + % (sum(1 for x in d if x["sso"]), sum(1 for x in d if not x["sso"]))) + + +if __name__ == "__main__": + main()