From f08dc68e2044788bfeaaabeaebd4fc949a19e075 Mon Sep 17 00:00:00 2001 From: fencl Date: Sun, 5 Oct 2025 16:45:20 +0200 Subject: [PATCH] . --- update_homarr.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/update_homarr.yml b/update_homarr.yml index da0f981..1224ab8 100644 --- a/update_homarr.yml +++ b/update_homarr.yml @@ -54,12 +54,11 @@ state: present update_cache: yes - - name: Run Homarr update commands on VM (via SSH) + - name: Run Homarr update commands on VM (via SSH) # use SSHPASS env, hide item label ansible.builtin.command: argv: - sshpass - - -p - - "{{ vm_pass }}" + - -e # read password from SSHPASS environment - ssh - -o - StrictHostKeyChecking=no @@ -69,10 +68,15 @@ - bash - -lc - "{{ ('sudo ' if use_sudo else '') + item }}" + environment: + SSHPASS: "{{ vm_pass }}" # supply password via environment loop: "{{ homarr_commands }}" + loop_control: + index_var: idx # capture loop index + label: "cmd-{{ idx }}" # avoid printing full command in (item=...) line register: homarr_cmds changed_when: false - no_log: "{{ DEBUG == 0 }}" + no_log: "{{ DEBUG == 0 }}" # hide outputs and env when not debugging - name: Show outputs for each Homarr command ansible.builtin.debug: @@ -86,12 +90,15 @@ loop: "{{ homarr_cmds.results }}" when: DEBUG == 1 - - name: Fail play if any Homarr command failed + - name: Fail play if any Homarr command failed # also hide item label ansible.builtin.assert: that: "item.rc == 0" fail_msg: "Homarr update failed on VM: {{ item.item }} (rc={{ item.rc }})" success_msg: "All Homarr update commands succeeded." loop: "{{ homarr_cmds.results }}" + loop_control: + index_var: idx + label: "cmd-{{ idx }}" # ------------------------- # Readiness checks (controller first, then VM fallback) @@ -115,12 +122,11 @@ failed_when: false changed_when: false - - name: Homarr | VM-side fetch (HTML via Python, with retries) + - name: Homarr | VM-side fetch (HTML via Python, with retries) # use SSHPASS env here too ansible.builtin.command: argv: - sshpass - - -p - - "{{ vm_pass }}" + - -e - ssh - -o - StrictHostKeyChecking=no @@ -139,13 +145,14 @@ except Exception: pass PY + environment: + SSHPASS: "{{ vm_pass }}" register: homarr_vm changed_when: false failed_when: false when: homarr_controller.status | default(0) != 200 or homarr_controller.content is not defined retries: "{{ homarr_retries }}" delay: "{{ homarr_delay }}" - # Wait until we actually got some HTML that likely belongs to Homarr until: (homarr_vm.stdout | default('') | trim | length) > 0 and ('Homarr' in (homarr_vm.stdout | default(''))) no_log: "{{ DEBUG == 0 }}"