Compare commits
2 Commits
b9284f280f
...
b9e622e5c2
| Author | SHA1 | Date | |
|---|---|---|---|
| b9e622e5c2 | |||
| 2f88108a8d |
@@ -9,6 +9,7 @@
|
|||||||
hosts: localhost
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
become: false
|
||||||
tags: [install, update, export]
|
tags: [install, update, export]
|
||||||
tasks:
|
tasks:
|
||||||
- name: Generate global index.html and open in browser
|
- name: Generate global index.html and open in browser
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ hysteria2_configure_firewall: true
|
|||||||
hysteria2_config_path: /etc/hysteria/config.yaml
|
hysteria2_config_path: /etc/hysteria/config.yaml
|
||||||
hysteria2_service_name: hysteria-server
|
hysteria2_service_name: hysteria-server
|
||||||
|
|
||||||
|
# Официальный install_server.sh: хранится в roles/hysteria2/files/, синхронизируется с get.hy2.sh
|
||||||
|
hysteria2_install_script_url: "https://get.hy2.sh/"
|
||||||
|
hysteria2_install_script_name: install_server.sh
|
||||||
|
hysteria2_install_script_staging_dir: "{{ playbook_dir }}/.cache/hysteria2"
|
||||||
|
hysteria2_install_script_remote_path: /tmp/hysteria2-install_server.sh
|
||||||
|
|
||||||
hysteria2_output_dir: "{{ playbook_dir }}/output"
|
hysteria2_output_dir: "{{ playbook_dir }}/output"
|
||||||
hysteria2_output_name: "{{ inventory_hostname }}"
|
hysteria2_output_name: "{{ inventory_hostname }}"
|
||||||
|
|
||||||
|
|||||||
Executable
+1170
File diff suppressed because it is too large
Load Diff
@@ -54,7 +54,7 @@
|
|||||||
dest: "{{ hysteria2_output_dir }}/{{ hysteria2_output_name }}/index.html"
|
dest: "{{ hysteria2_output_dir }}/{{ hysteria2_output_name }}/index.html"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
vars:
|
vars:
|
||||||
generated_at: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}"
|
generated_at: "{{ now(utc=false, fmt='%Y-%m-%d %H:%M:%S') }}"
|
||||||
hysteria2_obfs_password: "{{ hysteria2_obfs_password }}"
|
hysteria2_obfs_password: "{{ hysteria2_obfs_password }}"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
dest: "{{ hysteria2_output_dir }}/index.html"
|
dest: "{{ hysteria2_output_dir }}/index.html"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
vars:
|
vars:
|
||||||
generated_at: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}"
|
generated_at: "{{ now(utc=false, fmt='%Y-%m-%d %H:%M:%S') }}"
|
||||||
total_users: "{{ hysteria2_global_servers | map(attribute='users') | map('length') | sum }}"
|
total_users: "{{ hysteria2_global_servers | map(attribute='users') | map('length') | sum }}"
|
||||||
when: hysteria2_global_servers | default([]) | length > 0
|
when: hysteria2_global_servers | default([]) | length > 0
|
||||||
become: false
|
become: false
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
when:
|
when:
|
||||||
- hysteria2_open_browser | bool
|
- hysteria2_open_browser | bool
|
||||||
- hysteria2_global_servers | default([]) | length > 0
|
- hysteria2_global_servers | default([]) | length > 0
|
||||||
- ansible_system == 'Darwin'
|
- ansible_facts['system'] == 'Darwin'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
become: false
|
become: false
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
when:
|
when:
|
||||||
- hysteria2_open_browser | bool
|
- hysteria2_open_browser | bool
|
||||||
- hysteria2_global_servers | default([]) | length > 0
|
- hysteria2_global_servers | default([]) | length > 0
|
||||||
- ansible_system == 'Linux'
|
- ansible_facts['system'] == 'Linux'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
become: false
|
become: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|||||||
@@ -23,11 +23,18 @@
|
|||||||
+ (['qrencode'] if hysteria2_generate_qr_png | bool else [])
|
+ (['qrencode'] if hysteria2_generate_qr_png | bool else [])
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
- name: Sync official Hysteria2 install script on control node
|
||||||
|
ansible.builtin.import_tasks: sync_install_script.yml
|
||||||
|
|
||||||
|
- name: Copy Hysteria2 install script to server
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ hysteria2_install_script_name }}"
|
||||||
|
dest: "{{ hysteria2_install_script_remote_path }}"
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
- name: Install Hysteria2 via official script
|
- name: Install Hysteria2 via official script
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command:
|
||||||
cmd: bash <(curl -fsSL https://get.hy2.sh/)
|
cmd: "{{ hysteria2_install_script_remote_path }}"
|
||||||
executable: /bin/bash
|
|
||||||
args:
|
|
||||||
creates: /usr/local/bin/hysteria
|
creates: /usr/local/bin/hysteria
|
||||||
register: _hysteria2_install
|
register: _hysteria2_install
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
---
|
||||||
|
- name: Ensure staging directory for install script sync
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ hysteria2_install_script_staging_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: "0700"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
- name: Fetch official install script for version check
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ hysteria2_install_script_url }}"
|
||||||
|
dest: "{{ hysteria2_install_script_staging_dir }}/{{ hysteria2_install_script_name }}.remote"
|
||||||
|
mode: "0644"
|
||||||
|
force: true
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
run_once: true
|
||||||
|
register: _hysteria2_remote_script
|
||||||
|
|
||||||
|
- name: Stat local install script in role files
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ role_path }}/files/{{ hysteria2_install_script_name }}"
|
||||||
|
checksum_algorithm: sha256
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
run_once: true
|
||||||
|
register: _hysteria2_local_script
|
||||||
|
|
||||||
|
- name: Stat remote install script from official server
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ hysteria2_install_script_staging_dir }}/{{ hysteria2_install_script_name }}.remote"
|
||||||
|
checksum_algorithm: sha256
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
run_once: true
|
||||||
|
register: _hysteria2_remote_script_stat
|
||||||
|
|
||||||
|
- name: Update bundled install script when official version is newer
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ hysteria2_install_script_staging_dir }}/{{ hysteria2_install_script_name }}.remote"
|
||||||
|
dest: "{{ role_path }}/files/{{ hysteria2_install_script_name }}"
|
||||||
|
mode: "0755"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
run_once: true
|
||||||
|
when: >-
|
||||||
|
not _hysteria2_local_script.stat.exists
|
||||||
|
or _hysteria2_local_script.stat.checksum
|
||||||
|
!= _hysteria2_remote_script_stat.stat.checksum
|
||||||
|
register: _hysteria2_script_updated
|
||||||
|
|
||||||
|
- name: Report install script sync result
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: >-
|
||||||
|
{{
|
||||||
|
'Официальный install_server.sh обновлён в roles/hysteria2/files/'
|
||||||
|
if (_hysteria2_script_updated.changed | default(false))
|
||||||
|
else 'Локальный install_server.sh актуален (совпадает с ' ~ hysteria2_install_script_url ~ ')'
|
||||||
|
}}
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
run_once: true
|
||||||
@@ -1,8 +1,16 @@
|
|||||||
---
|
---
|
||||||
|
- name: Sync official Hysteria2 install script on control node
|
||||||
|
ansible.builtin.import_tasks: sync_install_script.yml
|
||||||
|
|
||||||
|
- name: Copy Hysteria2 install script to server
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ hysteria2_install_script_name }}"
|
||||||
|
dest: "{{ hysteria2_install_script_remote_path }}"
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
- name: Update Hysteria2 binary via official script
|
- name: Update Hysteria2 binary via official script
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command:
|
||||||
cmd: bash <(curl -fsSL https://get.hy2.sh/)
|
cmd: "{{ hysteria2_install_script_remote_path }} --force"
|
||||||
executable: /bin/bash
|
|
||||||
register: _hysteria2_update
|
register: _hysteria2_update
|
||||||
notify: Restart hysteria-server
|
notify: Restart hysteria-server
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user