Newer Older
135 lines | 5.163kb
Xdev Host Manager authored a week ago
1
# Jumper Deployment
2

            
Bogdan Timofte authored 5 days ago
3
Host Manager rulează pe jumper ca serviciu Perl local, ascultând numai pe `127.0.0.1:8088`. Nginx publică aplicația prin vhost HTTPS pe IP-ul de management `192.168.2.100:443`; portul `80` redirecționează către HTTPS.
Xdev Host Manager authored a week ago
4

            
5
Vhost implicit:
6

            
7
```text
Bogdan Timofte authored 3 days ago
8
madagascar.xdev.ro
Xdev Host Manager authored a week ago
9
```
10

            
11
Instanța curentă este instalată pe jumper în `/usr/local/xdev-host-manager` și publicată prin nginx. `/opt` rămâne rezervat pentru aplicații 3rd party/vendor.
12

            
13
## Pachete
14

            
15
Se folosesc doar pachete din distribuție:
16

            
17
- `perl`
Bogdan Timofte authored 4 days ago
18
- `perl-DBI` / `perl-DBD-SQLite` dacă nu sunt deja disponibile
19
- `sqlite`
Xdev Host Manager authored a week ago
20
- `nginx`
21

            
22
Nu se instalează npm, pip sau CPAN direct pe host.
23

            
24
Dacă nginx nu este instalat pe jumper, se instalează din repo-ul distribuției:
25

            
26
```bash
27
sudo dnf install nginx
28
```
29

            
30
## Layout recomandat
31

            
32
```text
33
/usr/local/xdev-host-manager
34
  config/hosts.yaml
35
  config/local-hosts.tsv
Bogdan Timofte authored 4 days ago
36
  var/host-manager.sqlite
Xdev Host Manager authored a week ago
37
  scripts/host_manager.pl
Bogdan Timofte authored 5 days ago
38
  scripts/mdns_host_seed.pl
Xdev Host Manager authored a week ago
39
  scripts/sync_local_hosts.sh
Bogdan Timofte authored 3 days ago
40
  deploy/mikrotik/dhcp-lease-push.rsc
Xdev Host Manager authored a week ago
41

            
42
/etc/xdev/host-manager.env
43
/etc/systemd/system/host-manager.service
Bogdan Timofte authored 5 days ago
44
/etc/systemd/system/host-manager-mdns.service
Bogdan Timofte authored 2 days ago
45
/etc/systemd/system/host-manager-dns-publish.path
46
/etc/systemd/system/host-manager-dns-publish.service
Bogdan Timofte authored 3 days ago
47
/etc/nginx/conf.d/madagascar.xdev.ro.conf
Xdev Host Manager authored a week ago
48
```
49

            
50
## Instalare manuală
51

            
52
Pe jumper:
53

            
54
```bash
55
id -u host-manager >/dev/null 2>&1 || sudo useradd --system --home-dir /usr/local/xdev-host-manager --shell /usr/sbin/nologin host-manager
56
sudo install -d -o host-manager -g host-manager /usr/local/xdev-host-manager
57
sudo install -d -m 0750 /etc/xdev
58
sudo install -m 0644 deploy/jumper/host-manager.service /etc/systemd/system/host-manager.service
Bogdan Timofte authored 5 days ago
59
sudo install -m 0644 deploy/jumper/host-manager-mdns.service /etc/systemd/system/host-manager-mdns.service
Bogdan Timofte authored 2 days ago
60
sudo install -m 0644 deploy/jumper/host-manager-dns-publish.path /etc/systemd/system/host-manager-dns-publish.path
61
sudo install -m 0644 deploy/jumper/host-manager-dns-publish.service /etc/systemd/system/host-manager-dns-publish.service
Bogdan Timofte authored 3 days ago
62
sudo install -m 0644 deploy/jumper/nginx-host-manager.conf /etc/nginx/conf.d/madagascar.xdev.ro.conf
Xdev Host Manager authored a week ago
63
```
64

            
65
Copiază `deploy/jumper/host-manager.env.example` la `/etc/xdev/host-manager.env` și setează secretul TOTP real.
Bogdan Timofte authored 3 days ago
66
Nginx așteaptă certificatul TLS local CA la `/etc/pki/tls/certs/madagascar.xdev.ro.crt` și cheia la `/etc/pki/tls/private/madagascar.xdev.ro.key`.
Xdev Host Manager authored a week ago
67

            
68
La instalarea inițială se poate genera automat secretul TOTP. URI-ul de bootstrap rămâne doar pe jumper, root-only:
69

            
70
```bash
71
sudo cat /etc/xdev/host-manager.totp-uri
72
```
73

            
74
Validare:
75

            
76
```bash
77
sudo systemctl daemon-reload
78
sudo systemctl enable --now host-manager
Bogdan Timofte authored 5 days ago
79
sudo systemctl enable --now host-manager-mdns
Bogdan Timofte authored 2 days ago
80
sudo systemctl enable --now host-manager-dns-publish.path
Xdev Host Manager authored a week ago
81
sudo nginx -t
82
sudo systemctl reload nginx
83
curl -fsS http://127.0.0.1:8088/healthz
Bogdan Timofte authored 3 days ago
84
curl -k -o /dev/null -w '%{http_code}\n' https://madagascar.xdev.ro/healthz
Bogdan Timofte authored 5 days ago
85
# trebuie să întoarcă 404; healthcheck-ul public nu este expus prin nginx
Xdev Host Manager authored a week ago
86
```
87

            
88
Verificări de securitate de bază:
89

            
90
```bash
Bogdan Timofte authored 3 days ago
91
curl -k -o /dev/null -w '%{http_code}\n' -X POST https://madagascar.xdev.ro/api/render/local-hosts-tsv
Xdev Host Manager authored a week ago
92
# trebuie să întoarcă 401 fără sesiune OTP
93
```
94

            
95
## DNS local
96

            
97
Vhost-ul trebuie să existe în registrul intern:
98

            
99
```text
Bogdan Timofte authored 3 days ago
100
madagascar.xdev.ro -> jumper.madagascar.xdev.ro
Xdev Host Manager authored a week ago
101
```
102

            
103
Nu se adaugă wildcard local. Doar acest nume exact trebuie publicat.
Bogdan Timofte authored 5 days ago
104

            
Bogdan Timofte authored 2 days ago
105
Schimbările DNS făcute prin aplicație regenerează `config/local-hosts.tsv` și
106
ating `var/dns-publish.trigger`. Pe jumper,
107
`host-manager-dns-publish.path` pornește imediat
108
`host-manager-dns-publish.service`, care rulează:
109

            
110
```bash
111
/usr/local/xdev-host-manager/scripts/sync_local_hosts.sh --apply --verify
112
```
113

            
114
Serviciul oneshot rulează ca root prin systemd, deoarece publicarea atinge
115
`/etc/hosts`, `dnscrypt-proxy`, `systemd-resolved` și DNS-ul static de pe as01.
116

            
Bogdan Timofte authored 4 days ago
117
## Runtime store
118

            
119
`var/host-manager.sqlite` este sursa de adevăr pentru registry și Work Orders. La prima pornire, aplicația seed-uiește documentele lipsă din `config/hosts.yaml` și `config/work-orders.yaml`; ulterior push-urile de cod nu trebuie să înlocuiască baza runtime.
120

            
Bogdan Timofte authored 5 days ago
121
## mDNS discovery
122

            
Bogdan Timofte authored 4 days ago
123
`host-manager-mdns` este un listener separat care observă mDNS și scrie direct în tabelul SQLite `mdns_observations`. Listenerul nu modifică host registry-ul, `config/hosts.yaml` sau `config/local-hosts.tsv`. Sync-ul resolverului citește manifestul runtime din SQLite, nu din exportul static.
Bogdan Timofte authored 3 days ago
124

            
125
## DHCP lease push
126

            
127
Lease-urile DHCP de pe routerul `192.168.2.1` sunt colectate prin push HTTP de pe MikroTik către:
128

            
129
```text
Bogdan Timofte authored 3 days ago
130
POST https://192.168.2.100/api/collect/dhcp-leases
Bogdan Timofte authored 3 days ago
131
```
132

            
133
Setează `HOST_MANAGER_DHCP_PUSH_TOKEN` în `/etc/xdev/host-manager.env` și același token în `deploy/mikrotik/dhcp-lease-push.rsc` înainte de importul pe router. Endpoint-ul acceptă headerul `X-DHCP-Push-Token` sau `Authorization: Bearer ...` și scrie observații în `dhcp_leases`.
134

            
135
Scriptul RouterOS folosește `lease-script`, deci trimite evenimentele noi/modificate. Dacă routerul are deja un `lease-script`, îmbină manual codul din `deploy/mikrotik/dhcp-lease-push.rsc`.