fix: пересборка output/index.html при uninstall с LIMIT

Второй play перенесён на hysteria2_servers с run_once на localhost,
чтобы LIMIT не пропускал пересборку. Пустой index.html удаляется.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Sergey Antropoff
2026-07-01 13:31:28 +03:00
parent 13af9e814c
commit 56ccf6ed39
4 changed files with 24 additions and 11 deletions
+2 -1
View File
@@ -292,7 +292,8 @@ hysteria2_obfs_password: "{{ vault_hysteria2_obfs_passwords[inventory_hostname]
На **control node**: На **control node**:
- удаляется `output/<имя_сервера>/`; - удаляется `output/<имя_сервера>/`;
- пересобирается общий `output/index.html`. - пересобирается общий `output/index.html` (сервер убирается из списка; при `LIMIT=...` тоже);
- если серверов не осталось — `output/index.html` удаляется.
--- ---
+13 -8
View File
@@ -10,14 +10,19 @@
tasks_from: uninstall.yml tasks_from: uninstall.yml
- name: Rebuild global output index after uninstall - name: Rebuild global output index after uninstall
hosts: localhost hosts: hysteria2_servers
connection: local gather_facts: false
gather_facts: true
become: false
tags: [uninstall] tags: [uninstall]
tasks: tasks:
- name: Regenerate output/index.html from remaining servers - name: Regenerate output/index.html without removed server
ansible.builtin.include_role: block:
name: hysteria2 - name: Run global export tasks
tasks_from: export_global.yml 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 when: hysteria2_uninstall_rebuild_global_index | default(true) | bool
+8 -1
View File
@@ -56,6 +56,13 @@
when: hysteria2_global_servers | default([]) | length > 0 when: hysteria2_global_servers | default([]) | length > 0
become: false 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) - name: Open global index in default browser (macOS)
ansible.builtin.command: ansible.builtin.command:
cmd: open "{{ hysteria2_output_dir }}/index.html" cmd: open "{{ hysteria2_output_dir }}/index.html"
@@ -87,6 +94,6 @@
- name: Skip global index when no servers exported - name: Skip global index when no servers exported
ansible.builtin.debug: 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 when: hysteria2_global_servers | default([]) | length == 0
become: false become: false
+1 -1
View File
@@ -127,5 +127,5 @@
Hysteria2 (Salamander) полностью удалён с {{ inventory_hostname }}. Hysteria2 (Salamander) полностью удалён с {{ inventory_hostname }}.
Локальная папка {{ hysteria2_output_dir }}/{{ hysteria2_output_name }}/ удалена. Локальная папка {{ hysteria2_output_dir }}/{{ hysteria2_output_name }}/ удалена.
{% if hysteria2_uninstall_rebuild_global_index | default(true) | bool %} {% if hysteria2_uninstall_rebuild_global_index | default(true) | bool %}
Глобальный {{ hysteria2_output_dir }}/index.html будет пересобран. {{ hysteria2_output_dir }}/index.html будет пересобран без этого сервера.
{% endif %} {% endif %}