fix(netbird): вынести адрес машины и домен в inventory

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
karpenokandCursor committed 2026-11-08 01:07:19 +07:00
1 parent bb6bb5969d
commit a23232ac1c
10 files changed
+64 -42

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
# Значения ключей сюда не записывать.
COMPOSE_PROJECT_NAME=netbird
NETBIRD_DOMAIN=
NETBIRD_LETSENCRYPT_EMAIL=
NETBIRD_AUTH_SECRET=
NETBIRD_DATASTORE_KEY=
+1 -1
View File
@@ -10,7 +10,7 @@
| `compose.yaml` | Сервисы, порты `80/tcp`, `443/tcp`, `3478/udp` |
| `templates/config.yaml.j2` | Шаблон сервера. Ключи подставляет плейбук |
| `templates/env.j2` | Шаблон `.env` для Compose |
| `dashboard.env` | Публичные адреса панели |
| `templates/dashboard.env.j2` | Адреса панели. Имя берётся из `inventory/group_vars/netbird.yml` |
| `.env.example` | Имена переменных без значений |
`.env` и готовый `config.yaml` остаются на хосте в `/opt/netbird`. В git их нет. Повторный прогон не пересоздаёт ключи и не удаляет тома `netbird_data` и `netbird_traefik_letsencrypt`.
+3 -3
View File
@@ -66,7 +66,7 @@ services:
condition: service_healthy
labels:
- traefik.enable=true
- traefik.http.routers.netbird-dashboard.rule=Host(`central.gunihome.ru`)
- traefik.http.routers.netbird-dashboard.rule=Host(`${NETBIRD_DOMAIN}`)
- traefik.http.routers.netbird-dashboard.entrypoints=websecure
- traefik.http.routers.netbird-dashboard.tls=true
- traefik.http.routers.netbird-dashboard.tls.certresolver=letsencrypt
@@ -107,13 +107,13 @@ services:
command: ["--config", "/etc/netbird/config.yaml"]
labels:
- traefik.enable=true
- traefik.http.routers.netbird-grpc.rule=Host(`central.gunihome.ru`) && (PathPrefix(`/signalexchange.SignalExchange/`) || PathPrefix(`/management.ManagementService/`) || PathPrefix(`/management.ProxyService/`))
- traefik.http.routers.netbird-grpc.rule=Host(`${NETBIRD_DOMAIN}`) && (PathPrefix(`/signalexchange.SignalExchange/`) || PathPrefix(`/management.ManagementService/`) || PathPrefix(`/management.ProxyService/`))
- traefik.http.routers.netbird-grpc.entrypoints=websecure
- traefik.http.routers.netbird-grpc.tls=true
- traefik.http.routers.netbird-grpc.tls.certresolver=letsencrypt
- traefik.http.routers.netbird-grpc.service=netbird-server-h2c
- traefik.http.routers.netbird-grpc.priority=100
- traefik.http.routers.netbird-backend.rule=Host(`central.gunihome.ru`) && (PathPrefix(`/relay`) || PathPrefix(`/ws-proxy/`) || PathPrefix(`/api`) || PathPrefix(`/oauth2`))
- traefik.http.routers.netbird-backend.rule=Host(`${NETBIRD_DOMAIN}`) && (PathPrefix(`/relay`) || PathPrefix(`/ws-proxy/`) || PathPrefix(`/api`) || PathPrefix(`/oauth2`))
- traefik.http.routers.netbird-backend.entrypoints=websecure
- traefik.http.routers.netbird-backend.tls=true
- traefik.http.routers.netbird-backend.tls.certresolver=letsencrypt
+24 -7
View File
@@ -24,6 +24,7 @@
- ufw
- openssl
- ca-certificates
- curl
state: present
update_cache: true
@@ -122,16 +123,21 @@
no_log: true
when: not netbird_env.stat.exists
- name: Положить манифесты панели
- name: Положить манифест панели
ansible.builtin.copy:
src: "{{ playbook_dir }}/{{ item }}"
dest: "{{ netbird_dir }}/{{ item }}"
src: "{{ playbook_dir }}/compose.yaml"
dest: "{{ netbird_dir }}/compose.yaml"
owner: root
group: root
mode: "0644"
- name: Собрать dashboard.env
ansible.builtin.template:
src: dashboard.env.j2
dest: "{{ netbird_dir }}/dashboard.env"
owner: root
group: root
mode: "0644"
loop:
- compose.yaml
- dashboard.env
- name: Собрать config.yaml
ansible.builtin.template:
@@ -156,6 +162,17 @@
register: compose_ps
changed_when: false
- name: Дождаться ответа панели
ansible.builtin.command: >
curl -sk --resolve {{ netbird_domain }}:443:127.0.0.1
-o /dev/null -w '%{http_code}'
https://{{ netbird_domain }}/
register: panel_http
changed_when: false
retries: 30
delay: 10
until: panel_http.stdout in ['200', '302']
- name: Итог установки
ansible.builtin.debug:
msg: "{{ compose_ps.stdout_lines + ['Первый вход: https://central.gunihome.ru/setup'] }}"
msg: "{{ compose_ps.stdout_lines + ['Первый вход: https://' + netbird_domain + '/setup'] }}"
+4 -4
View File
@@ -2,7 +2,7 @@
server:
listenAddress: ":80"
exposedAddress: "https://central.gunihome.ru:443"
exposedAddress: "https://{{ netbird_domain }}:443"
stunPorts:
- 3478
metricsPort: 9090
@@ -14,12 +14,12 @@ server:
dataDir: "/var/lib/netbird"
auth:
issuer: "https://central.gunihome.ru/oauth2"
issuer: "https://{{ netbird_domain }}/oauth2"
signKeyRefreshEnabled: true
sessionCookieEncryptionKey: "{{ netbird_session_key }}"
dashboardRedirectURIs:
- "https://central.gunihome.ru/nb-auth"
- "https://central.gunihome.ru/nb-silent-auth"
- "https://{{ netbird_domain }}/nb-auth"
- "https://{{ netbird_domain }}/nb-silent-auth"
cliRedirectURIs:
- "http://localhost:53000/"
@@ -1,10 +1,10 @@
# Панель за Traefik. Сертификат выпускает Traefik, поэтому LETSENCRYPT_DOMAIN=none.
NETBIRD_MGMT_API_ENDPOINT=https://central.gunihome.ru
NETBIRD_MGMT_GRPC_API_ENDPOINT=https://central.gunihome.ru
NETBIRD_MGMT_API_ENDPOINT=https://{{ netbird_domain }}
NETBIRD_MGMT_GRPC_API_ENDPOINT=https://{{ netbird_domain }}
AUTH_AUDIENCE=netbird-dashboard
AUTH_CLIENT_ID=netbird-dashboard
AUTH_CLIENT_SECRET=
AUTH_AUTHORITY=https://central.gunihome.ru/oauth2
AUTH_AUTHORITY=https://{{ netbird_domain }}/oauth2
USE_AUTH0=false
AUTH_SUPPORTED_SCOPES=openid profile email groups
AUTH_REDIRECT_URI=/nb-auth
+1
View File
@@ -1,4 +1,5 @@
COMPOSE_PROJECT_NAME=netbird
NETBIRD_DOMAIN={{ netbird_domain }}
NETBIRD_LETSENCRYPT_EMAIL={{ netbird_letsencrypt_email }}
NETBIRD_AUTH_SECRET={{ netbird_auth_secret }}
NETBIRD_DATASTORE_KEY={{ netbird_datastore_key }}