diff --git a/ansible/ci/deploy-machine.sh b/ansible/ci/deploy-machine.sh index 1cc266c..762f5f9 100755 --- a/ansible/ci/deploy-machine.sh +++ b/ansible/ci/deploy-machine.sh @@ -96,9 +96,6 @@ case "$machine" in rus-central) input_email="${INPUT_LETSENCRYPT_EMAIL:-}" eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/services/netbird" --format=dotenv-export --silent)" - eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/services/remnawave" --format=dotenv-export --silent 2>/dev/null || true)" - export REMNANODE_SECRET_KEY="${REMNANODE_SECRET_KEY:-}" - export CLOUDFLARE_API="${CLOUDFLARE_API:-}" export NETBIRD_AUTH_SECRET="${NETBIRD_AUTH_SECRET:-}" export NETBIRD_DATASTORE_KEY="${NETBIRD_DATASTORE_KEY:-}" export NETBIRD_SESSION_KEY="${NETBIRD_SESSION_KEY:-}" diff --git a/ansible/inventories/prod/host_vars/ger-nod-02.yml b/ansible/inventories/prod/host_vars/ger-nod-02.yml index e61f1d6..8a4c2ce 100644 --- a/ansible/inventories/prod/host_vars/ger-nod-02.yml +++ b/ansible/inventories/prod/host_vars/ger-nod-02.yml @@ -2,12 +2,6 @@ ansible_host: 150.241.64.209 ansible_user: root remnanode_selfsteal_domain: "yali.gunis.top" -remnanode_public_ip: "2a12:bec4:1bb0:2e80::2" -remnanode_wait_host: "2a12:bec4:1bb0:2e80::2" -remnanode_dns_record_type: "AAAA" -remnanode_ipv6_only: true -remnanode_cascade_allowed_ips: - - "2a06:dd00:1:4::6bd1" # WAN egress панели (core-net): оба провайдера → NODE_PORT remnanode_panel_egress_ips: - "213.128.28.107" # провайдер 1 (МТС) diff --git a/ansible/inventories/prod/host_vars/rus-central.yml b/ansible/inventories/prod/host_vars/rus-central.yml index c26161c..9c776f5 100644 --- a/ansible/inventories/prod/host_vars/rus-central.yml +++ b/ansible/inventories/prod/host_vars/rus-central.yml @@ -1,11 +1,2 @@ --- netbird_domain: central.gunihome.ru -remnanode_public_ip: "31.177.108.210" -remnanode_wait_host: "31.177.108.210" -remnanode_allow_panel_wan: true -remnanode_selfsteal_domain: "lulu.gunihome.ru" -remnanode_cloudflare_zone: "gunihome.ru" -remnanode_xhttp_path: "/xhttp-lulu" -remnanode_panel_egress_ips: - - "213.128.28.107" # провайдер 1 (МТС) - - "185.160.137.140" # провайдер 2 (NorCom) diff --git a/ansible/playbooks/rus-central.yml b/ansible/playbooks/rus-central.yml index 870b3fa..c0b18a2 100644 --- a/ansible/playbooks/rus-central.yml +++ b/ansible/playbooks/rus-central.yml @@ -5,7 +5,5 @@ roles: - role: rus-central/netbird tags: [netbird] - - role: remnanode - tags: [remnanode] - role: rus-central/cadvisor tags: [cadvisor] diff --git a/ansible/roles/core-net/remnawave/files/nodes.yml b/ansible/roles/core-net/remnawave/files/nodes.yml index 5c590a6..72bd41a 100644 --- a/ansible/roles/core-net/remnawave/files/nodes.yml +++ b/ansible/roles/core-net/remnawave/files/nodes.yml @@ -15,20 +15,8 @@ nodes: country_code: "DE" profile_name: "DE-Yali" profile_template: "profile-selfsteal-xhttp.json" - inbound_tag: "Cascade-RU-DE" - create_host: false + inbound_tag: "Steal-Yali" selfsteal_domain: "yali.gunis.top" xhttp_path: "/xhttp-yali" host_remark: "🇩🇪 ger-nod-02" - - name: Rus-central - address: "31.177.108.210" - port: 2222 - country_code: "RU" - profile_name: "RU-Cascade" - profile_template: "profile-cascade-ru.json" - inbound_tag: "Steal-Lulu" - selfsteal_domain: "lulu.gunihome.ru" - xhttp_path: "/xhttp-lulu" - host_remark: "🇷🇺→🇩🇪 lulu" - diff --git a/ansible/roles/core-net/remnawave/files/profile-cascade-ru.json b/ansible/roles/core-net/remnawave/files/profile-cascade-ru.json deleted file mode 100644 index a235ee8..0000000 --- a/ansible/roles/core-net/remnawave/files/profile-cascade-ru.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "log": { - "loglevel": "warning" - }, - "dns": { - "servers": [ - { - "address": "https://dns.google/dns-query", - "skipFallback": false - } - ], - "queryStrategy": "UseIP" - }, - "inbounds": [ - { - "tag": "__INBOUND_TAG__", - "listen": "31.177.108.210", - "port": 443, - "protocol": "vless", - "settings": { - "clients": [], - "decryption": "none" - }, - "sniffing": { - "enabled": true, - "destOverride": ["http", "tls", "quic"] - }, - "streamSettings": { - "network": "xhttp", - "security": "reality", - "xhttpSettings": { - "host": "__SELFSTEAL_DOMAIN__", - "mode": "stream-one", - "path": "__XHTTP_PATH__" - }, - "realitySettings": { - "dest": "/dev/shm/nginx.sock", - "show": false, - "xver": 1, - "spiderX": "", - "shortIds": ["__REALITY_SHORT_ID__"], - "privateKey": "__REALITY_PRIVATE_KEY__", - "serverNames": ["__SELFSTEAL_DOMAIN__"] - } - } - } - ], - "outbounds": [ - { - "tag": "CASCADE-DE", - "protocol": "vless", - "settings": { - "vnext": [ - { - "address": "2a12:bec4:1bb0:2e80::2", - "port": 443, - "users": [ - { - "id": "__CASCADE_UUID__", - "encryption": "none", - "flow": "xtls-rprx-vision" - } - ] - } - ] - }, - "streamSettings": { - "network": "tcp", - "security": "reality", - "realitySettings": { - "serverName": "yali.gunis.top", - "fingerprint": "chrome", - "publicKey": "__CASCADE_PUBLIC_KEY__", - "shortId": "__CASCADE_SHORT_ID__" - } - } - }, - { - "tag": "BLOCK", - "protocol": "blackhole" - } - ], - "routing": { - "domainStrategy": "AsIs", - "rules": [ - { - "type": "field", - "ip": ["geoip:private"], - "outboundTag": "BLOCK" - }, - { - "type": "field", - "protocol": ["bittorrent"], - "outboundTag": "BLOCK" - }, - { - "type": "field", - "network": "tcp,udp", - "outboundTag": "CASCADE-DE" - } - ] - } -} - diff --git a/ansible/roles/core-net/remnawave/files/sync_remnawave.py b/ansible/roles/core-net/remnawave/files/sync_remnawave.py index 166baf8..41929d2 100644 --- a/ansible/roles/core-net/remnawave/files/sync_remnawave.py +++ b/ansible/roles/core-net/remnawave/files/sync_remnawave.py @@ -9,7 +9,6 @@ import re import secrets import subprocess import sys -import uuid from typing import Any @@ -178,136 +177,12 @@ def sync_xray_template( return tpl_uuid -def generate_x25519(api: RemnawaveAPI) -> tuple[str, str]: - _, key_resp = api.request("GET", "/system/tools/x25519/generate") - resp_obj = key_resp.get("response") or key_resp - keypairs = resp_obj.get("keypairs") or [] - first = keypairs[0] if keypairs else resp_obj - priv = first.get("privateKey") or first.get("privKey") or "" - pub = first.get("publicKey") or first.get("pubKey") or "" - if not priv or not pub: - raise RuntimeError("Не удалось сгенерировать X25519 ключ Reality") - return priv, pub - - -def ensure_cascade_credentials( - api: RemnawaveAPI, - changes: list[str], -) -> dict[str, str]: - """Ensure DE-Yali has Cascade-RU-DE inbound and return credentials if RU-Cascade needs creation.""" - _, profiles_resp = api.request("GET", "/config-profiles/") - profiles = _extract_list(profiles_resp, "configProfiles") - de_prof = next((p for p in profiles if p.get("name") == "DE-Yali"), None) - ru_prof = next((p for p in profiles if p.get("name") == "RU-Cascade"), None) - if not de_prof: - return {} - - de_uuid = de_prof["uuid"] - _, de_full = api.request("GET", f"/config-profiles/{de_uuid}") - de_obj = de_full.get("response") or de_full - de_cfg = de_obj.get("config") or {} - inbounds = de_cfg.get("inbounds") or [] - has_cascade_inb = any( - i.get("tag") == "Cascade-RU-DE" - and i.get("port") == 443 - and ((i.get("streamSettings") or {}).get("realitySettings") or {}).get("dest") == "/dev/shm/nginx.sock" - for i in inbounds - ) - has_steal_yali = any(i.get("tag") == "Steal-Yali" for i in inbounds) - - ru_ok = False - if ru_prof: - _, ru_full = api.request("GET", f"/config-profiles/{ru_prof['uuid']}") - ru_cfg = (ru_full.get("response") or ru_full).get("config") or {} - for ob in ru_cfg.get("outbounds") or []: - if ob.get("tag") == "CASCADE-DE": - vnext = (ob.get("settings") or {}).get("vnext") or [] - rs = (ob.get("streamSettings") or {}).get("realitySettings") or {} - users = (vnext[0].get("users") or [{}]) if vnext else [{}] - if ( - vnext - and vnext[0].get("port") == 443 - and rs.get("serverName") == "yali.gunis.top" - and users[0].get("flow") == "xtls-rprx-vision" - ): - ru_ok = True - - if has_cascade_inb and not has_steal_yali and ru_ok: - return {} - - _, users_resp = api.request("GET", "/users/") - users_list = _extract_list(users_resp, "users") - homelab_user = next((u for u in users_list if u.get("username") == "homelab"), None) - cascade_uuid = (homelab_user or {}).get("vlessUuid") or str(uuid.uuid4()) - - priv, pub = generate_x25519(api) - creds = { - "uuid": cascade_uuid, - "priv": priv, - "pub": pub, - "short_id": secrets.token_hex(8), - } - cascade_inbound = { - "tag": "Cascade-RU-DE", - "listen": "2a12:bec4:1bb0:2e80::2", - "port": 443, - "protocol": "vless", - "settings": { - "clients": [{"id": creds["uuid"], "flow": "xtls-rprx-vision"}], - "decryption": "none", - }, - "sniffing": { - "enabled": True, - "destOverride": ["http", "tls", "quic"], - }, - "streamSettings": { - "network": "tcp", - "security": "reality", - "realitySettings": { - "dest": "/dev/shm/nginx.sock", - "show": False, - "xver": 1, - "spiderX": "", - "shortIds": [creds["short_id"]], - "privateKey": creds["priv"], - "serverNames": ["yali.gunis.top"], - }, - }, - } - new_inbounds = [ - i for i in inbounds - if i.get("tag") not in ("Cascade-RU-DE", "Steal-Yali") - ] - new_inbounds.append(cascade_inbound) - de_cfg["inbounds"] = new_inbounds - api.request("PATCH", "/config-profiles/", {"uuid": de_uuid, "config": de_cfg}) - changes.append("updated profile DE-Yali to IPv6-only SelfSteal Cascade-RU-DE") - if ru_prof: - _, ru_full = api.request("GET", f"/config-profiles/{ru_prof['uuid']}") - ru_cfg = (ru_full.get("response") or ru_full).get("config") or {} - for ob in ru_cfg.get("outbounds") or []: - if ob.get("tag") == "CASCADE-DE": - vnext = (ob.get("settings") or {}).get("vnext") or [] - if vnext: - vnext[0]["port"] = 443 - vnext[0]["users"][0]["id"] = creds["uuid"] - vnext[0]["users"][0]["flow"] = "xtls-rprx-vision" - rs = (ob.get("streamSettings") or {}).get("realitySettings") or {} - rs["serverName"] = "yali.gunis.top" - rs["publicKey"] = creds["pub"] - rs["shortId"] = creds["short_id"] - api.request("PATCH", "/config-profiles/", {"uuid": ru_prof["uuid"], "config": ru_cfg}) - changes.append("updated profile RU-Cascade to SelfSteal yali.gunis.top") - return creds - - def ensure_profile_and_inbound( api: RemnawaveAPI, node_cfg: dict[str, Any], profile_templates: dict[str, str], - cascade_creds: dict[str, str], changes: list[str], -) -> tuple[str, str, list[str]]: +) -> tuple[str, str]: profile_name = node_cfg["profile_name"] inbound_tag = node_cfg["inbound_tag"] @@ -320,10 +195,19 @@ def ensure_profile_and_inbound( raw_tpl = profile_templates.get(tpl_key) if not raw_tpl: raise RuntimeError(f"Не найден шаблон профиля {tpl_key}") - if isinstance(raw_tpl, dict): - raw_tpl = json.dumps(raw_tpl) - priv, _ = generate_x25519(api) + _, key_resp = api.request("GET", "/system/tools/x25519/generate") + resp_obj = key_resp.get("response") or key_resp + keypairs = resp_obj.get("keypairs") or [] + priv = ( + (keypairs[0].get("privateKey") if keypairs else None) + or resp_obj.get("privateKey") + or resp_obj.get("privKey") + or "" + ) + if not priv: + raise RuntimeError("Не удалось сгенерировать X25519 ключ Reality") + short_id = secrets.token_hex(8) rendered = ( raw_tpl.replace("__REALITY_PRIVATE_KEY__", priv) @@ -331,9 +215,6 @@ def ensure_profile_and_inbound( .replace("__INBOUND_TAG__", inbound_tag) .replace("__SELFSTEAL_DOMAIN__", node_cfg["selfsteal_domain"]) .replace("__XHTTP_PATH__", node_cfg["xhttp_path"]) - .replace("__CASCADE_UUID__", cascade_creds.get("uuid", "")) - .replace("__CASCADE_PUBLIC_KEY__", cascade_creds.get("pub", "")) - .replace("__CASCADE_SHORT_ID__", cascade_creds.get("short_id", "")) ) _, created = api.request( "POST", @@ -354,13 +235,7 @@ def ensure_profile_and_inbound( inbound_uuid = next((i["uuid"] for i in inbounds if i.get("tag") == inbound_tag), "") if not inbound_uuid: raise RuntimeError(f"Не найден inbound {inbound_tag} в профиле {profile_uuid}") - extra_uuids = [ - i["uuid"] - for tag in node_cfg.get("extra_inbound_tags", []) - for i in inbounds - if i.get("tag") == tag - ] - return profile_uuid, inbound_uuid, extra_uuids + return profile_uuid, inbound_uuid def sync_node_and_host( @@ -368,7 +243,6 @@ def sync_node_and_host( node_cfg: dict[str, Any], profile_uuid: str, inbound_uuid: str, - extra_inbound_uuids: list[str], tpl_uuid: str, nb_peers: dict[str, str], netbird_connected: bool, @@ -389,10 +263,9 @@ def sync_node_and_host( nodes = _extract_list(nodes_resp) existing_node = next((n for n in nodes if n.get("name") == node_name), None) - active_inbounds = [inbound_uuid] + extra_inbound_uuids desired_cp = { "activeConfigProfileUuid": profile_uuid, - "activeInbounds": active_inbounds, + "activeInbounds": [inbound_uuid], } if not existing_node: @@ -422,7 +295,7 @@ def sync_node_and_host( existing_node.get("address") != target_addr or int(existing_node.get("port") or 0) != int(node_cfg["port"]) or cur_cp.get("activeConfigProfileUuid") != profile_uuid - or set(cur_inbounds) != set(active_inbounds) + or cur_inbounds != [inbound_uuid] ) if needs_update: payload = { @@ -436,9 +309,6 @@ def sync_node_and_host( api.request("PUT", "/nodes/", payload) changes.append(f"updated node {node_name} ({target_addr})") - if not node_cfg.get("create_host", True): - return - selfsteal = node_cfg["selfsteal_domain"] _, hosts_resp = api.request("GET", "/hosts/") hosts = _extract_list(hosts_resp) @@ -519,7 +389,7 @@ def cleanup_removed_nodes_and_hosts( desired_nodes: list[dict[str, Any]], changes: list[str], ) -> None: - desired_domains = {n["selfsteal_domain"] for n in desired_nodes if n.get("create_host", True)} + desired_domains = {n["selfsteal_domain"] for n in desired_nodes} desired_node_names = {n["name"] for n in desired_nodes} desired_profile_names = {n["profile_name"] for n in desired_nodes} @@ -715,21 +585,17 @@ def main() -> int: changes, ) - cascade_creds = ensure_cascade_credentials(api, changes) - inbound_uuids: list[str] = [] for node_cfg in cfg.get("nodes", []): - profile_uuid, inbound_uuid, extra_inbound_uuids = ensure_profile_and_inbound( - api, node_cfg, cfg.get("profile_templates", {}), cascade_creds, changes + profile_uuid, inbound_uuid = ensure_profile_and_inbound( + api, node_cfg, cfg.get("profile_templates", {}), changes ) inbound_uuids.append(inbound_uuid) - inbound_uuids.extend(extra_inbound_uuids) sync_node_and_host( api, node_cfg, profile_uuid, inbound_uuid, - extra_inbound_uuids, tpl_uuid, nb_peers, bool(cfg.get("netbird_connected")), diff --git a/ansible/roles/core-net/remnawave/tasks/sync.yml b/ansible/roles/core-net/remnawave/tasks/sync.yml index cb527d4..e84842f 100644 --- a/ansible/roles/core-net/remnawave/tasks/sync.yml +++ b/ansible/roles/core-net/remnawave/tasks/sync.yml @@ -27,7 +27,6 @@ users: "{{ remnawave_users_cfg.users | default([]) }}" profile_templates: profile-selfsteal-xhttp.json: "{{ lookup('file', role_path ~ '/files/profile-selfsteal-xhttp.json') }}" - profile-cascade-ru.json: "{{ lookup('file', role_path ~ '/files/profile-cascade-ru.json') }}" - name: Положить скрипт синхронизации Remnawave ansible.builtin.copy: @@ -51,15 +50,9 @@ RW_API_TOKEN: "{{ remnawave_api_token }}" NB_API_TOKEN: "{{ lookup('env', 'NETBIRD_API_TOKEN', default='') }}" register: remnawave_sync_raw - changed_when: remnawave_sync_raw.rc == 0 and (remnawave_sync_raw.stdout | from_json).changed - failed_when: false + changed_when: (remnawave_sync_raw.stdout | from_json).changed no_log: true -- name: Показать ошибку sync_remnawave.py без секретов - ansible.builtin.fail: - msg: "sync_remnawave.py failed (rc={{ remnawave_sync_raw.rc }}): {{ remnawave_sync_raw.stderr | default('') }}" - when: remnawave_sync_raw.rc != 0 - - name: Разобрать результат синхронизации Remnawave ansible.builtin.set_fact: remnawave_sync: "{{ remnawave_sync_raw.stdout | from_json }}" diff --git a/ansible/roles/core-net/traefik/files/dynamic/lulu.yml b/ansible/roles/core-net/traefik/files/dynamic/lulu.yml deleted file mode 100644 index 765f3e9..0000000 --- a/ansible/roles/core-net/traefik/files/dynamic/lulu.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Xray cascade TCP SNI passthrough -> rus-central VPS (31.177.108.210:443) -tcp: - routers: - lulu-cascade: - rule: HostSNI(`lulu.gunihome.ru`) - entryPoints: - - websecure - service: lulu-cascade - tls: - passthrough: true - - services: - lulu-cascade: - loadBalancer: - servers: - - address: "31.177.108.210:443" diff --git a/ansible/roles/opnsense/xray/files/instances.yml b/ansible/roles/opnsense/xray/files/instances.yml index bddeca6..849f13d 100644 --- a/ansible/roles/opnsense/xray/files/instances.yml +++ b/ansible/roles/opnsense/xray/files/instances.yml @@ -18,7 +18,4 @@ instances: active: false - name: "🇩🇪Germ-02" secret: GERM_02 - active: false - - name: "🇷🇺→🇩🇪Caskad-01" - secret: CASKAD_01 active: true diff --git a/ansible/roles/remnanode/defaults/main.yml b/ansible/roles/remnanode/defaults/main.yml index 13dfdba..5db37d4 100644 --- a/ansible/roles/remnanode/defaults/main.yml +++ b/ansible/roles/remnanode/defaults/main.yml @@ -3,12 +3,6 @@ remnanode_dir: /opt/remnanode remnanode_image: "remnawave/node:latest" remnanode_nginx_image: "nginx:1.28" remnanode_node_port: 2222 -remnanode_public_ip: "{{ ansible_host }}" -remnanode_wait_host: "127.0.0.1" -remnanode_allow_panel_wan: false -remnanode_dns_record_type: "A" -remnanode_ipv6_only: false -remnanode_cascade_allowed_ips: [] remnanode_selfsteal_domain: "yali.gunis.top" remnanode_xhttp_path: "/xhttp-yali" diff --git a/ansible/roles/remnanode/tasks/main.yml b/ansible/roles/remnanode/tasks/main.yml index 770689c..f207b18 100644 --- a/ansible/roles/remnanode/tasks/main.yml +++ b/ansible/roles/remnanode/tasks/main.yml @@ -52,9 +52,9 @@ ansible.builtin.set_fact: remnanode_cf_zone_id: "{{ (cf_zones.json.result | first).id }}" -- name: Найти существующую DNS-запись SelfSteal ({{ remnanode_dns_record_type }}) +- name: Найти существующую A-запись SelfSteal ansible.builtin.uri: - url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records?type={{ remnanode_dns_record_type }}&name={{ remnanode_selfsteal_domain }}" + url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records?type=A&name={{ remnanode_selfsteal_domain }}" headers: Authorization: "Bearer {{ remnanode_cloudflare_api }}" Content-Type: application/json @@ -63,19 +63,18 @@ register: cf_dns_lookup no_log: true -- name: Найти старую A-запись SelfSteal (если AAAA) +- name: Найти старую AAAA-запись SelfSteal ansible.builtin.uri: - url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records?type=A&name={{ remnanode_selfsteal_domain }}" + url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records?type=AAAA&name={{ remnanode_selfsteal_domain }}" headers: Authorization: "Bearer {{ remnanode_cloudflare_api }}" Content-Type: application/json return_content: true status_code: 200 - register: cf_old_a_lookup - when: remnanode_dns_record_type == "AAAA" + register: cf_old_aaaa_lookup no_log: true -- name: Удалить старую A-запись SelfSteal при переходе на IPv6-only +- name: Удалить старую AAAA-запись SelfSteal ansible.builtin.uri: url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records/{{ item.id }}" method: DELETE @@ -83,13 +82,10 @@ Authorization: "Bearer {{ remnanode_cloudflare_api }}" Content-Type: application/json status_code: 200 - loop: "{{ (cf_old_a_lookup.json.result | default([])) }}" - when: - - remnanode_dns_record_type == "AAAA" - - cf_old_a_lookup is defined + loop: "{{ cf_old_aaaa_lookup.json.result | default([]) }}" no_log: true -- name: Создать DNS-запись SelfSteal ({{ remnanode_dns_record_type }}) +- name: Создать A-запись SelfSteal ansible.builtin.uri: url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records" method: POST @@ -98,16 +94,16 @@ Content-Type: application/json body_format: json body: - type: "{{ remnanode_dns_record_type }}" + type: A name: "{{ remnanode_selfsteal_domain }}" - content: "{{ remnanode_public_ip }}" + content: "{{ ansible_host }}" ttl: 120 proxied: false status_code: [200, 201] when: (cf_dns_lookup.json.result | length) == 0 no_log: true -- name: Обновить DNS-запись SelfSteal ({{ remnanode_dns_record_type }}) +- name: Обновить A-запись SelfSteal ansible.builtin.uri: url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records/{{ (cf_dns_lookup.json.result | first).id }}" method: PUT @@ -116,16 +112,16 @@ Content-Type: application/json body_format: json body: - type: "{{ remnanode_dns_record_type }}" + type: A name: "{{ remnanode_selfsteal_domain }}" - content: "{{ remnanode_public_ip }}" + content: "{{ ansible_host }}" ttl: 120 proxied: false status_code: 200 when: >- (cf_dns_lookup.json.result | length) > 0 and ( - (cf_dns_lookup.json.result | first).content != remnanode_public_ip or + (cf_dns_lookup.json.result | first).content != ansible_host or (cf_dns_lookup.json.result | first).proxied ) no_log: true @@ -159,27 +155,15 @@ path: /root/.secrets/cloudflare.ini state: absent -- name: Разрешить HTTP для Let's Encrypt HTTP-01 (dual-stack) +- name: Разрешить HTTP для Let's Encrypt HTTP-01 ansible.builtin.command: ufw allow 80/tcp register: ufw_http changed_when: "'added' in (ufw_http.stdout | lower)" - when: not (remnanode_ipv6_only | bool) - -- name: Закрыть общий 80/tcp и открыть 80/tcp только для IPv6 (HTTP-01) - ansible.builtin.command: "{{ item }}" - loop: - - ufw --force delete allow 80/tcp - - "ufw allow from ::/0 to {{ remnanode_public_ip }} port 80 proto tcp" - register: ufw_http_v6 - changed_when: "'added' in (ufw_http_v6.stdout | lower)" - failed_when: false - when: remnanode_ipv6_only | bool - name: Выпустить/обновить сертификат через HTTP-01 (без TXT в Cloudflare) ansible.builtin.command: > certbot certonly --standalone - --http-01-address {{ remnanode_public_ip }} --non-interactive --agree-tos --email {{ remnanode_letsencrypt_email }} @@ -215,21 +199,6 @@ ansible.builtin.command: ufw allow 443/tcp register: ufw_https changed_when: "'added' in (ufw_https.stdout | lower)" - when: not (remnanode_ipv6_only | bool) - -- name: Закрыть общий 443/tcp и открыть 443/tcp только для разрешённых IPv6-каскадов - ansible.builtin.command: ufw --force delete allow 443/tcp - register: ufw_https_del - changed_when: "'deleted' in (ufw_https_del.stdout | lower)" - failed_when: false - when: remnanode_ipv6_only | bool - -- name: Разрешить 443/tcp только с входных IPv6 каскада - ansible.builtin.command: "ufw allow from {{ item }} to {{ remnanode_public_ip }} port 443 proto tcp" - loop: "{{ remnanode_cascade_allowed_ips }}" - register: ufw_https_v6 - changed_when: "'added' in (ufw_https_v6.stdout | lower)" - when: remnanode_ipv6_only | bool - name: Узнать NetBird IP панели ansible.builtin.shell: | @@ -256,9 +225,7 @@ ufw allow from {{ remnanode_panel_nb.stdout | trim }} to any port {{ remnanode_node_port }} proto tcp register: ufw_node_nb changed_when: "'added' in (ufw_node_nb.stdout | lower)" - when: - - not (remnanode_allow_panel_wan | bool) - - remnanode_panel_nb.stdout | default('') | trim is match('^[0-9.]+$') + when: remnanode_panel_nb.stdout | default('') | trim is match('^[0-9.]+$') - name: Убрать WAN-доступ к NODE_PORT ansible.builtin.command: > @@ -267,9 +234,7 @@ register: ufw_node_wan_del changed_when: "'deleted' in (stdout | default('') | lower)" failed_when: false - when: - - not (remnanode_allow_panel_wan | bool) - - remnanode_panel_nb.stdout | default('') | trim is match('^[0-9.]+$') + when: remnanode_panel_nb.stdout | default('') | trim is match('^[0-9.]+$') - name: Разрешить NODE_PORT только с egress панели (оба провайдера) ansible.builtin.command: > @@ -277,7 +242,7 @@ loop: "{{ remnanode_panel_egress_ips }}" register: ufw_node changed_when: "'added' in (stdout | default('') | lower)" - when: (remnanode_allow_panel_wan | bool) or (remnanode_panel_nb.stdout | default('') | trim is not match('^[0-9.]+$')) + when: remnanode_panel_nb.stdout | default('') | trim is not match('^[0-9.]+$') - name: Включить firewall ansible.builtin.command: ufw --force enable @@ -301,7 +266,7 @@ - name: Дождаться 443 после конфига с панели ansible.builtin.wait_for: port: 443 - host: "{{ remnanode_wait_host }}" + host: 127.0.0.1 timeout: 180 register: remnanode_wait_443 failed_when: false diff --git a/ansible/roles/rus-central/netbird/files/compose.yaml b/ansible/roles/rus-central/netbird/files/compose.yaml index 49f8a58..d1c367b 100644 --- a/ansible/roles/rus-central/netbird/files/compose.yaml +++ b/ansible/roles/rus-central/netbird/files/compose.yaml @@ -33,10 +33,8 @@ services: - "--ping.entrypoint=ping" - "--entrypoints.ping.address=:8082" ports: - - "45.154.185.208:443:443" - - "127.0.0.1:443:443" - - "45.154.185.208:80:80" - - "127.0.0.1:80:80" + - "443:443" + - "80:80" volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - netbird_traefik_letsencrypt:/letsencrypt