refactor: split machine deploys from one-time secrets migration
Roles stay under the machine that runs them, CI applies only a known product, and the /opt/secrets move is a one-shot playbook instead of part of every core-secrets run. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
341538fba9
commit
9c692522fb
85 files changed
+537
-492
No files matched your search
@@ -0,0 +1,12 @@
|
||||
---
|
||||
netbird_dir: /opt/netbird
|
||||
netbird_ports:
|
||||
- 80/tcp
|
||||
- 443/tcp
|
||||
- 3478/udp
|
||||
|
||||
netbird_letsencrypt_email: "{{ letsencrypt_email }}"
|
||||
|
||||
netbird_auth_secret: "{{ lookup('env', 'NETBIRD_AUTH_SECRET') }}"
|
||||
netbird_datastore_key: "{{ lookup('env', 'NETBIRD_DATASTORE_KEY') }}"
|
||||
netbird_session_key: "{{ lookup('env', 'NETBIRD_SESSION_KEY') }}"
|
||||
@@ -0,0 +1,6 @@
|
||||
COMPOSE_PROJECT_NAME=netbird
|
||||
NETBIRD_DOMAIN=
|
||||
NETBIRD_LETSENCRYPT_EMAIL=
|
||||
NETBIRD_AUTH_SECRET=
|
||||
NETBIRD_DATASTORE_KEY=
|
||||
NETBIRD_SESSION_KEY=
|
||||
@@ -0,0 +1,152 @@
|
||||
name: netbird
|
||||
|
||||
services:
|
||||
traefik:
|
||||
image: traefik:v3.7.14
|
||||
container_name: netbird-traefik
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
netbird:
|
||||
ipv4_address: 172.30.0.10
|
||||
command:
|
||||
- "--log.level=INFO"
|
||||
- "--accesslog=true"
|
||||
- "--providers.docker=true"
|
||||
- "--providers.docker.exposedbydefault=false"
|
||||
- "--providers.docker.network=netbird_netbird"
|
||||
- "--entrypoints.web.address=:80"
|
||||
- "--entrypoints.websecure.address=:443"
|
||||
- "--entrypoints.websecure.allowACMEByPass=true"
|
||||
- "--entrypoints.web.http.aliasHeadersStrategy=delete"
|
||||
- "--entrypoints.websecure.http.aliasHeadersStrategy=delete"
|
||||
- "--entrypoints.websecure.transport.respondingTimeouts.readTimeout=0"
|
||||
- "--entrypoints.websecure.transport.respondingTimeouts.writeTimeout=0"
|
||||
- "--entrypoints.websecure.transport.respondingTimeouts.idleTimeout=0"
|
||||
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
|
||||
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
|
||||
- "--certificatesresolvers.letsencrypt.acme.email=${NETBIRD_LETSENCRYPT_EMAIL}"
|
||||
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
|
||||
- "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
|
||||
- "--serverstransport.forwardingtimeouts.responseheadertimeout=0s"
|
||||
- "--serverstransport.forwardingtimeouts.idleconntimeout=0s"
|
||||
- "--ping=true"
|
||||
- "--ping.entrypoint=ping"
|
||||
- "--entrypoints.ping.address=:8082"
|
||||
ports:
|
||||
- "443:443"
|
||||
- "80:80"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- netbird_traefik_letsencrypt:/letsencrypt
|
||||
healthcheck:
|
||||
test: ["CMD", "traefik", "healthcheck", "--ping", "--ping.entrypoint=ping", "--entrypoints.ping.address=:8082"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "500m"
|
||||
max-file: "2"
|
||||
|
||||
dashboard:
|
||||
image: netbirdio/dashboard@sha256:340b13c00b84349572a2acc5605e907cb09250a9e6461c757097eabdb8e02f2c
|
||||
container_name: netbird-dashboard
|
||||
restart: unless-stopped
|
||||
networks: [netbird]
|
||||
env_file:
|
||||
- ./dashboard.env
|
||||
depends_on:
|
||||
server-health:
|
||||
condition: service_healthy
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- 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
|
||||
- traefik.http.routers.netbird-dashboard.service=dashboard
|
||||
- traefik.http.routers.netbird-dashboard.priority=1
|
||||
- traefik.http.services.dashboard.loadbalancer.server.port=80
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "500m"
|
||||
max-file: "2"
|
||||
|
||||
dashboard-health:
|
||||
image: curlimages/curl:8.22.0
|
||||
network_mode: service:dashboard
|
||||
depends_on:
|
||||
dashboard:
|
||||
condition: service_started
|
||||
entrypoint: ["sleep", "infinity"]
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-fsS", "http://127.0.0.1/"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 15s
|
||||
restart: unless-stopped
|
||||
|
||||
netbird-server:
|
||||
image: netbirdio/netbird-server:0.82.0
|
||||
container_name: netbird-server
|
||||
restart: unless-stopped
|
||||
networks: [netbird]
|
||||
ports:
|
||||
- "3478:3478/udp"
|
||||
volumes:
|
||||
- netbird_data:/var/lib/netbird
|
||||
- ./config.yaml:/etc/netbird/config.yaml:ro
|
||||
command: ["--config", "/etc/netbird/config.yaml"]
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- 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(`${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
|
||||
- traefik.http.routers.netbird-backend.service=netbird-server
|
||||
- traefik.http.routers.netbird-backend.priority=100
|
||||
- traefik.http.services.netbird-server.loadbalancer.server.port=80
|
||||
- traefik.http.services.netbird-server-h2c.loadbalancer.server.port=80
|
||||
- traefik.http.services.netbird-server-h2c.loadbalancer.server.scheme=h2c
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "500m"
|
||||
max-file: "2"
|
||||
|
||||
server-health:
|
||||
image: curlimages/curl:8.22.0
|
||||
network_mode: service:netbird-server
|
||||
depends_on:
|
||||
netbird-server:
|
||||
condition: service_started
|
||||
entrypoint: ["sleep", "infinity"]
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:80/oauth2/.well-known/openid-configuration"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 12
|
||||
start_period: 20s
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
netbird_data:
|
||||
netbird_traefik_letsencrypt:
|
||||
|
||||
networks:
|
||||
netbird:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.30.0.0/24
|
||||
gateway: 172.30.0.1
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Перезапустить NetBird
|
||||
ansible.builtin.command: docker compose up -d --force-recreate --remove-orphans
|
||||
args:
|
||||
chdir: "{{ netbird_dir }}"
|
||||
register: compose_up
|
||||
changed_when: "'Started' in compose_up.stderr or 'Created' in compose_up.stderr or 'Recreated' in compose_up.stderr"
|
||||
tags: [always]
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
---
|
||||
- name: Разрешить порты панели
|
||||
ansible.builtin.command: ufw allow {{ item }}
|
||||
register: ufw_rule
|
||||
changed_when: "'added' in (ufw_rule.stdout | lower)"
|
||||
loop: "{{ netbird_ports }}"
|
||||
|
||||
- name: Поставить openssl
|
||||
ansible.builtin.apt:
|
||||
name: openssl
|
||||
state: present
|
||||
|
||||
- name: Создать каталог панели
|
||||
ansible.builtin.file:
|
||||
path: "{{ netbird_dir }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
|
||||
- name: Проверить наличие обязательных секретов NetBird
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- netbird_domain is defined and netbird_domain | length > 3
|
||||
- netbird_auth_secret is defined and netbird_auth_secret | length > 0
|
||||
- netbird_datastore_key is defined and netbird_datastore_key | length > 0
|
||||
- netbird_session_key is defined and netbird_session_key | length > 0
|
||||
- netbird_letsencrypt_email is defined and netbird_letsencrypt_email | length > 3
|
||||
fail_msg: "Не задан домен NetBird (host_vars) или один из секретов NETBIRD_AUTH_SECRET, NETBIRD_DATASTORE_KEY, NETBIRD_SESSION_KEY, NETBIRD_LETSENCRYPT_EMAIL."
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Записать .env
|
||||
ansible.builtin.template:
|
||||
src: env.j2
|
||||
dest: "{{ netbird_dir }}/.env"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
no_log: true
|
||||
notify: Перезапустить NetBird
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Положить манифест панели
|
||||
ansible.builtin.copy:
|
||||
src: compose.yaml
|
||||
dest: "{{ netbird_dir }}/compose.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Перезапустить NetBird
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Собрать dashboard.env
|
||||
ansible.builtin.template:
|
||||
src: dashboard.env.j2
|
||||
dest: "{{ netbird_dir }}/dashboard.env"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Перезапустить NetBird
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Собрать config.yaml
|
||||
ansible.builtin.template:
|
||||
src: config.yaml.j2
|
||||
dest: "{{ netbird_dir }}/config.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
no_log: true
|
||||
notify: Перезапустить NetBird
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Применить изменения конфигурации
|
||||
ansible.builtin.meta: flush_handlers
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Убедиться, что панель запущена
|
||||
ansible.builtin.command: docker compose up -d
|
||||
args:
|
||||
chdir: "{{ netbird_dir }}"
|
||||
register: compose_up
|
||||
changed_when: "'Started' in compose_up.stderr or 'Created' in compose_up.stderr or 'Recreated' in compose_up.stderr"
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Показать состояние контейнеров
|
||||
ansible.builtin.command: docker compose ps
|
||||
args:
|
||||
chdir: "{{ netbird_dir }}"
|
||||
register: compose_ps
|
||||
changed_when: false
|
||||
tags:
|
||||
- config
|
||||
|
||||
- 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']
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Итог установки
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ compose_ps.stdout_lines + ['Первый вход: https://' + netbird_domain + '/setup'] }}"
|
||||
tags:
|
||||
- config
|
||||
@@ -0,0 +1,32 @@
|
||||
server:
|
||||
listenAddress: ":80"
|
||||
exposedAddress: "https://{{ netbird_domain }}:443"
|
||||
stunPorts:
|
||||
- 3478
|
||||
metricsPort: 9090
|
||||
healthcheckAddress: ":9000"
|
||||
logLevel: "info"
|
||||
logFile: "console"
|
||||
|
||||
authSecret: "{{ netbird_auth_secret }}"
|
||||
dataDir: "/var/lib/netbird"
|
||||
|
||||
auth:
|
||||
issuer: "https://{{ netbird_domain }}/oauth2"
|
||||
signKeyRefreshEnabled: true
|
||||
sessionCookieEncryptionKey: "{{ netbird_session_key }}"
|
||||
dashboardRedirectURIs:
|
||||
- "https://{{ netbird_domain }}/nb-auth"
|
||||
- "https://{{ netbird_domain }}/nb-silent-auth"
|
||||
cliRedirectURIs:
|
||||
- "http://localhost:53000/"
|
||||
|
||||
reverseProxy:
|
||||
trustedHTTPProxies:
|
||||
- "172.30.0.10/32"
|
||||
trustedPeers:
|
||||
- "172.30.0.10/32"
|
||||
|
||||
store:
|
||||
engine: "sqlite"
|
||||
encryptionKey: "{{ netbird_datastore_key }}"
|
||||
@@ -0,0 +1,12 @@
|
||||
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://{{ netbird_domain }}/oauth2
|
||||
USE_AUTH0=false
|
||||
AUTH_SUPPORTED_SCOPES=openid profile email groups
|
||||
AUTH_REDIRECT_URI=/nb-auth
|
||||
AUTH_SILENT_REDIRECT_URI=/nb-silent-auth
|
||||
NGINX_SSL_PORT=443
|
||||
LETSENCRYPT_DOMAIN=none
|
||||
@@ -0,0 +1,6 @@
|
||||
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 }}
|
||||
NETBIRD_SESSION_KEY={{ netbird_session_key }}
|
||||
Reference in new issue
Block a user