chore: remove NetBird and Authentik layers from homelab
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 3s
ansible-deploy / deploy (core-mon, ) (push) Successful in 39s
ansible-deploy / deploy (core-net, ) (push) Successful in 57s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 25s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 57s
ansible-deploy / deploy (opnsense, ) (push) Successful in 15s
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 3s
ansible-deploy / deploy (core-mon, ) (push) Successful in 39s
ansible-deploy / deploy (core-net, ) (push) Successful in 57s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 25s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 57s
ansible-deploy / deploy (opnsense, ) (push) Successful in 15s
This commit is contained in:
1 parent
6417bdcc75
commit
6a2f90797a
55 files changed
+134
-2460
No files matched your search
@@ -26,7 +26,6 @@ remnawave_metrics_pass: "{{ lookup('env', 'REMNAWAVE_METRICS_PASS', default='')
|
||||
remnawave_webhook_secret: "{{ lookup('env', 'REMNAWAVE_WEBHOOK_SECRET_HEADER', default='') }}"
|
||||
remnawave_api_token: "{{ lookup('env', 'REMNAWAVE_API_TOKEN', default='') }}"
|
||||
|
||||
remnawave_netbird_peers_url: "https://central.gunihome.ru/api/peers"
|
||||
remnawave_xray_checker_user: "homelab"
|
||||
remnawave_api_token_name: "infra-automation"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Шаблоны команд Remnawave API. Новый однотипный ресурс — шаг здесь.
|
||||
# prepare/compare_with/after/run — короткие хуки в sync_remnawave.py
|
||||
# (ключ Reality, адрес NetBird, uuid профилей, правило Browser, пользователи).
|
||||
# (ключ Reality, uuid профилей, правило Browser, пользователи).
|
||||
# {поле} подставляется из элемента. Целая строка "{поле}" сохраняет тип (объект, список).
|
||||
steps:
|
||||
- id: xray_templates
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Желаемое состояние панели Remnawave.
|
||||
# Новая выходная нода: запись в nodes, профиль (если новый), сквад, хост в inventory
|
||||
# (группы remnanodes и exit_nodes, имя с «-nod-»). Повторный прогон панели — тег remnawave_sync,
|
||||
# (группа remnanodes, имя с «-nod-»). Повторный прогон панели — тег remnawave_sync,
|
||||
# без pull образов. Сквад, нода, host и профиль, которых здесь нет, с панели удаляются.
|
||||
# Тег inbound уникален среди профилей.
|
||||
|
||||
@@ -25,7 +25,7 @@ subscription_page_config: Homelab
|
||||
nodes:
|
||||
- name: Ger-nod-02
|
||||
address: "150.241.64.209"
|
||||
netbird_hostname: ger-nod-02
|
||||
hostname: ger-nod-02
|
||||
port: 2222
|
||||
country_code: DE
|
||||
profile: DE-Yali
|
||||
|
||||
@@ -71,36 +71,6 @@ class RemnawaveAPI:
|
||||
return status, data
|
||||
|
||||
|
||||
def resolve_netbird_peers(peers_url: str, nb_token: str) -> dict[str, str]:
|
||||
if not peers_url or not nb_token:
|
||||
return {}
|
||||
proc = subprocess.run(
|
||||
["curl", "-fsS", "--max-time", "20", "-H", f"Authorization: Token {nb_token}", peers_url],
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
return {}
|
||||
try:
|
||||
raw = json.loads(proc.stdout.decode("utf-8", errors="replace"))
|
||||
except json.JSONDecodeError:
|
||||
return {}
|
||||
peers = raw if isinstance(raw, list) else (raw.get("items") or raw.get("peers") or [])
|
||||
mapping: dict[str, str] = {}
|
||||
ip_re = re.compile(r"^\d+\.\d+\.\d+\.\d+$")
|
||||
for peer in peers:
|
||||
if not isinstance(peer, dict):
|
||||
continue
|
||||
ip = str(peer.get("ip") or "").strip()
|
||||
if not ip_re.match(ip):
|
||||
continue
|
||||
for key in ("hostname", "name", "dns_label"):
|
||||
val = str(peer.get(key) or "").strip()
|
||||
if val and val not in mapping:
|
||||
mapping[val] = ip
|
||||
return mapping
|
||||
|
||||
|
||||
def _extract_list(resp: Any, *keys: str) -> list[dict[str, Any]]:
|
||||
if isinstance(resp, dict):
|
||||
inner = resp.get("response", resp)
|
||||
@@ -197,14 +167,8 @@ class Sync:
|
||||
self.refs: dict[str, dict[str, dict[str, Any]]] = {}
|
||||
self.inbounds: dict[str, dict[str, Any]] = {}
|
||||
self.xray_url = ""
|
||||
self.peers: dict[str, str] = {}
|
||||
|
||||
def run(self) -> dict[str, Any]:
|
||||
if self.cfg.get("netbird_connected"):
|
||||
self.peers = resolve_netbird_peers(
|
||||
self.cfg.get("netbird_peers_url", ""),
|
||||
os.environ.get("NB_API_TOKEN", "").strip(),
|
||||
)
|
||||
pending: list[tuple[dict[str, Any], list[dict[str, Any]], set[tuple[Any, ...]]]] = []
|
||||
later = [step for step in self.commands if step.get("run")]
|
||||
for step in self.commands:
|
||||
@@ -388,13 +352,7 @@ class Sync:
|
||||
inbound = self.inbounds.get(profile["inbound_tag"])
|
||||
if not inbound or not inbound.get("uuid"):
|
||||
raise RuntimeError(f"Нет inbound {profile.get('inbound_tag')} у профиля {item['profile']}")
|
||||
host = item.get("netbird_hostname") or ""
|
||||
address = item["address"]
|
||||
if self.cfg.get("netbird_connected") and host and host in self.peers:
|
||||
address = self.peers[host]
|
||||
elif host:
|
||||
self.warnings.append(f"node {item['name']}: fallback-адрес {address} (NetBird peer {host} недоступен)")
|
||||
item["address"] = address
|
||||
item["address"] = item["address"]
|
||||
item["port"] = int(item["port"])
|
||||
item["countryCode"] = item["country_code"]
|
||||
item["configProfile"] = {
|
||||
@@ -652,8 +610,6 @@ def _selftest() -> None:
|
||||
cfg = {
|
||||
"panel_domain": "panel.example",
|
||||
"sub_domain": "sub.example",
|
||||
"netbird_connected": True,
|
||||
"netbird_peers_url": "",
|
||||
"xray_checker_user": "homelab",
|
||||
"desired": {
|
||||
"xray_templates": [{"name": "Except-RU", "templateType": "XRAY_JSON", "file": "xray-except-ru.json"}],
|
||||
@@ -669,7 +625,7 @@ def _selftest() -> None:
|
||||
"nodes": [{
|
||||
"name": "Ger-nod-02",
|
||||
"address": "150.241.64.209",
|
||||
"netbird_hostname": "ger-nod-02",
|
||||
"hostname": "ger-nod-02",
|
||||
"port": 2222,
|
||||
"country_code": "DE",
|
||||
"profile": "DE-Yali",
|
||||
@@ -702,7 +658,6 @@ def _selftest() -> None:
|
||||
return status, data
|
||||
|
||||
globals()["_rest"] = wrapped_rest
|
||||
os.environ["NB_API_TOKEN"] = ""
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
os.environ["RW_XRAY_URL_FILE"] = str(pathlib.Path(tmp) / "url")
|
||||
first = Sync(cfg, Fake()).run()
|
||||
|
||||
@@ -5,12 +5,6 @@
|
||||
remnawave_users_cfg: "{{ lookup('file', role_path ~ '/files/users.yml') | from_yaml }}"
|
||||
remnawave_commands: "{{ lookup('file', role_path ~ '/files/commands.yml') | from_yaml }}"
|
||||
|
||||
- name: Проверить, что панель сама в NetBird
|
||||
ansible.builtin.command: netbird status
|
||||
register: remnawave_local_netbird
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Собрать тексты JSON-шаблонов
|
||||
ansible.builtin.set_fact:
|
||||
remnawave_spec_files: "{{ remnawave_spec_files | default({}) | combine({item: lookup('file', role_path ~ '/files/' ~ item)}) }}"
|
||||
@@ -21,8 +15,6 @@
|
||||
remnawave_sync_payload:
|
||||
panel_domain: "{{ remnawave_panel_domain }}"
|
||||
sub_domain: "{{ remnawave_sub_domain }}"
|
||||
netbird_peers_url: "{{ remnawave_netbird_peers_url }}"
|
||||
netbird_connected: "{{ 'Management: Connected' in (remnawave_local_netbird.stdout | default('')) }}"
|
||||
xray_checker_user: "{{ remnawave_xray_checker_user }}"
|
||||
desired: "{{ remnawave_desired }}"
|
||||
users_doc: "{{ remnawave_users_cfg }}"
|
||||
@@ -49,7 +41,6 @@
|
||||
ansible.builtin.command: "python3 {{ remnawave_dir }}/sync_remnawave.py {{ remnawave_dir }}/sync_config.json"
|
||||
environment:
|
||||
RW_API_TOKEN: "{{ remnawave_api_token }}"
|
||||
NB_API_TOKEN: "{{ lookup('env', 'NETBIRD_API_TOKEN', default='') }}"
|
||||
RW_XRAY_URL_FILE: "{{ remnawave_dir }}/.xray-checker-url"
|
||||
register: remnawave_sync_raw
|
||||
changed_when: remnawave_sync_raw.rc == 0 and ((remnawave_sync_raw.stdout | from_json).changed | default(false))
|
||||
|
||||
Reference in new issue
Block a user