From a79ce464579c58e2501c85fd2c20764d46b50af3 Mon Sep 17 00:00:00 2001 From: Sergey Antropoff Date: Wed, 1 Jul 2026 13:31:28 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BF=D0=B5=D1=80=D0=B5=D1=81=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=BA=D0=B0=20output/index.html=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20uninstall=20=D1=81=20LIMIT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Второй play перенесён на hysteria2_servers с run_once на localhost, чтобы LIMIT не пропускал пересборку. Пустой index.html удаляется. Co-authored-by: Cursor --- README.md | 3 ++- playbook-uninstall.yml | 21 +++++++++++++-------- roles/hysteria2/tasks/export_global.yml | 9 ++++++++- roles/hysteria2/tasks/uninstall.yml | 2 +- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0fa6471..97eddc6 100644 --- a/README.md +++ b/README.md @@ -276,7 +276,8 @@ hysteria2_user_passwords: На **control node**: - удаляется `output/<имя_сервера>/`; -- пересобирается общий `output/index.html`. +- пересобирается общий `output/index.html` (сервер убирается из списка; при `LIMIT=...` тоже); +- если серверов не осталось — `output/index.html` удаляется. --- diff --git a/playbook-uninstall.yml b/playbook-uninstall.yml index 5a30083..8531a94 100644 --- a/playbook-uninstall.yml +++ b/playbook-uninstall.yml @@ -10,14 +10,19 @@ tasks_from: uninstall.yml - name: Rebuild global output index after uninstall - hosts: localhost - connection: local - gather_facts: true - become: false + hosts: hysteria2_servers + gather_facts: false tags: [uninstall] tasks: - - name: Regenerate output/index.html from remaining servers - ansible.builtin.include_role: - name: hysteria2 - tasks_from: export_global.yml + - name: Regenerate output/index.html without removed server + block: + - name: Run global export tasks + ansible.builtin.include_role: + name: hysteria2 + tasks_from: export_global.yml + vars: + hysteria2_open_browser: false + run_once: true + delegate_to: localhost + become: false when: hysteria2_uninstall_rebuild_global_index | default(true) | bool diff --git a/roles/hysteria2/tasks/export_global.yml b/roles/hysteria2/tasks/export_global.yml index bdcdc40..93c169f 100644 --- a/roles/hysteria2/tasks/export_global.yml +++ b/roles/hysteria2/tasks/export_global.yml @@ -54,6 +54,13 @@ when: hysteria2_global_servers | default([]) | length > 0 become: false +- name: Remove global HTML index when no servers remain + ansible.builtin.file: + path: "{{ hysteria2_output_dir }}/index.html" + state: absent + when: hysteria2_global_servers | default([]) | length == 0 + become: false + - name: Open global index in default browser (macOS) ansible.builtin.command: cmd: open "{{ hysteria2_output_dir }}/index.html" @@ -85,6 +92,6 @@ - name: Skip global index when no servers exported ansible.builtin.debug: - msg: "Глобальный index.html не создан — нет server-info.yml в {{ hysteria2_output_dir }}/" + msg: "Глобальный {{ hysteria2_output_dir }}/index.html удалён — нет server-info.yml в output/" when: hysteria2_global_servers | default([]) | length == 0 become: false diff --git a/roles/hysteria2/tasks/uninstall.yml b/roles/hysteria2/tasks/uninstall.yml index cb42ca8..97aa969 100644 --- a/roles/hysteria2/tasks/uninstall.yml +++ b/roles/hysteria2/tasks/uninstall.yml @@ -133,5 +133,5 @@ Hysteria2 полностью удалён с {{ inventory_hostname }}. Локальная папка {{ hysteria2_output_dir }}/{{ hysteria2_output_name }}/ удалена. {% if hysteria2_uninstall_rebuild_global_index | default(true) | bool %} - Глобальный {{ hysteria2_output_dir }}/index.html будет пересобран. + {{ hysteria2_output_dir }}/index.html будет пересобран без этого сервера. {% endif %}