From b83b69d309b08c49bf7e68a554076906d7daa878 Mon Sep 17 00:00:00 2001 From: Sergey Antropoff Date: Wed, 1 Jul 2026 11:56:06 +0300 Subject: [PATCH] fix: disable become on localhost play and drop deprecated facts Use now() for export timestamps and ansible_facts['system'] for browser detection. Set become: false on the localhost play to avoid sudo on local fact gathering. Co-authored-by: Cursor --- playbook.yml | 1 + roles/hysteria2/tasks/export.yml | 2 +- roles/hysteria2/tasks/export_global.yml | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/playbook.yml b/playbook.yml index 0bf8bb3..890e0f7 100644 --- a/playbook.yml +++ b/playbook.yml @@ -9,6 +9,7 @@ hosts: localhost connection: local gather_facts: true + become: false tags: [install, update, export] tasks: - name: Generate global index.html and open in browser diff --git a/roles/hysteria2/tasks/export.yml b/roles/hysteria2/tasks/export.yml index a540396..80ed715 100644 --- a/roles/hysteria2/tasks/export.yml +++ b/roles/hysteria2/tasks/export.yml @@ -54,7 +54,7 @@ dest: "{{ hysteria2_output_dir }}/{{ hysteria2_output_name }}/index.html" mode: "0644" 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 }}" delegate_to: localhost become: false diff --git a/roles/hysteria2/tasks/export_global.yml b/roles/hysteria2/tasks/export_global.yml index 6a2918c..302fe03 100644 --- a/roles/hysteria2/tasks/export_global.yml +++ b/roles/hysteria2/tasks/export_global.yml @@ -51,7 +51,7 @@ dest: "{{ hysteria2_output_dir }}/index.html" mode: "0644" 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 }}" when: hysteria2_global_servers | default([]) | length > 0 become: false @@ -62,7 +62,7 @@ when: - hysteria2_open_browser | bool - hysteria2_global_servers | default([]) | length > 0 - - ansible_system == 'Darwin' + - ansible_facts['system'] == 'Darwin' changed_when: false become: false @@ -72,7 +72,7 @@ when: - hysteria2_open_browser | bool - hysteria2_global_servers | default([]) | length > 0 - - ansible_system == 'Linux' + - ansible_facts['system'] == 'Linux' changed_when: false become: false failed_when: false