refactor(remnawave): синхронизировать панель из desired.yml и шаблонов команд
ansible-deploy / plan (push) Successful in 1s
ansible-lint / lint (push) Successful in 2s
ansible-deploy / deploy (core-mon, ) (push) Successful in 37s
ansible-deploy / deploy (core-net, ) (push) Failing after 52s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 24s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 1m20s
ansible-deploy / deploy (opnsense, ) (push) Successful in 13s
ansible-deploy / deploy (rus-central, ) (push) Successful in 1m6s
ansible-deploy / plan (push) Successful in 1s
ansible-lint / lint (push) Successful in 2s
ansible-deploy / deploy (core-mon, ) (push) Successful in 37s
ansible-deploy / deploy (core-net, ) (push) Failing after 52s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 24s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 1m20s
ansible-deploy / deploy (opnsense, ) (push) Successful in 13s
ansible-deploy / deploy (rus-central, ) (push) Successful in 1m6s
Повторный прогон без смены compose не тянет образы, ноды и сквады добавляются данными, а не новым плейбуком на каждый VPS. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
89f928c64a
commit
99ee815213
22 files changed
+1151
-672
No files matched your search
@@ -1,8 +1,9 @@
|
||||
---
|
||||
- name: Загрузить декларативную конфигурацию нод и пользователей Remnawave
|
||||
- name: Загрузить желаемое состояние и шаблоны команд Remnawave
|
||||
ansible.builtin.set_fact:
|
||||
remnawave_nodes_cfg: "{{ lookup('file', role_path ~ '/files/nodes.yml') | from_yaml }}"
|
||||
remnawave_desired: "{{ lookup('file', role_path ~ '/files/desired.yml') | from_yaml }}"
|
||||
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
|
||||
@@ -10,6 +11,11 @@
|
||||
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)}) }}"
|
||||
loop: "{{ ((remnawave_desired.xray_templates | default([]) | map(attribute='file') | list) + (remnawave_desired.profiles | default([]) | map(attribute='template') | list)) | unique }}"
|
||||
|
||||
- name: Собрать конфигурацию синхронизации Remnawave
|
||||
ansible.builtin.set_fact:
|
||||
remnawave_sync_payload:
|
||||
@@ -18,15 +24,10 @@
|
||||
netbird_peers_url: "{{ remnawave_netbird_peers_url }}"
|
||||
netbird_connected: "{{ 'Management: Connected' in (remnawave_local_netbird.stdout | default('')) }}"
|
||||
xray_checker_user: "{{ remnawave_xray_checker_user }}"
|
||||
xray_template: "{{ remnawave_nodes_cfg.xray_template }}"
|
||||
xray_template_json: "{{ lookup('file', role_path ~ '/files/' ~ remnawave_nodes_cfg.xray_template.file) | from_json }}"
|
||||
squad_name: "{{ remnawave_nodes_cfg.squad_name | default('Default-Squad') }}"
|
||||
subscription_page_config: "{{ remnawave_nodes_cfg.subscription_page_config | default('Homelab') }}"
|
||||
nodes: "{{ remnawave_nodes_cfg.nodes | default([]) }}"
|
||||
managed_tag: "{{ remnawave_users_cfg.managed_tag | default('IAC') }}"
|
||||
users: "{{ remnawave_users_cfg.users | default([]) }}"
|
||||
profile_templates:
|
||||
profile-selfsteal-xhttp.json: "{{ lookup('file', role_path ~ '/files/profile-selfsteal-xhttp.json') }}"
|
||||
desired: "{{ remnawave_desired }}"
|
||||
users_doc: "{{ remnawave_users_cfg }}"
|
||||
commands: "{{ remnawave_commands }}"
|
||||
files: "{{ remnawave_spec_files }}"
|
||||
|
||||
- name: Положить скрипт синхронизации Remnawave
|
||||
ansible.builtin.copy:
|
||||
@@ -44,17 +45,24 @@
|
||||
group: root
|
||||
mode: "0600"
|
||||
|
||||
- name: Синхронизировать шаблоны, профили, ноды, хосты и пользователей Remnawave
|
||||
- name: Синхронизировать шаблоны, профили, ноды, хосты, сквады и пользователей
|
||||
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))
|
||||
|
||||
- name: Прочитать ссылку Xray Checker
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ remnawave_dir }}/.xray-checker-url"
|
||||
register: remnawave_xray_url_file
|
||||
failed_when: false
|
||||
no_log: true
|
||||
|
||||
- name: Разобрать результат синхронизации Remnawave
|
||||
ansible.builtin.set_fact:
|
||||
remnawave_sync: "{{ remnawave_sync_raw.stdout | from_json }}"
|
||||
remnawave_xray_checker_url: "{{ (remnawave_sync_raw.stdout | from_json).xray_checker_subscription_url | default('') }}"
|
||||
remnawave_xray_checker_url: "{{ remnawave_xray_url_file.content | default('') | b64decode }}"
|
||||
no_log: true
|
||||
|
||||
Reference in new issue
Block a user