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

Второй play перенесён на hysteria2_servers с run_once на localhost,
чтобы LIMIT не пропускал пересборку. Пустой index.html удаляется.
This commit is contained in:
Sergey Antropoff
2026-07-01 13:31:28 +03:00
parent 4b5a1ef51f
commit 83b47dbc30
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**:
- удаляется `output/<имя_сервера>/`;
- пересобирается общий `output/index.html`.
- пересобирается общий `output/index.html` (сервер убирается из списка; при `LIMIT=...` тоже);
- если серверов не осталось — `output/index.html` удаляется.
---
+13 -8
View File
@@ -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
+8 -1
View File
@@ -56,6 +56,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"
@@ -87,6 +94,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
+1 -1
View File
@@ -127,5 +127,5 @@
Hysteria2 (Salamander) полностью удалён с {{ 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 %}