b9284f280f
Store install_server.sh in role files, compare SHA256 with get.hy2.sh on the control node before install/update, refresh the bundled copy when upstream changes, then copy and run it on VPS. Co-authored-by: Cursor <cursoragent@cursor.com>
65 lines
2.1 KiB
YAML
65 lines
2.1 KiB
YAML
---
|
|
- 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
|