3
0
forked from jakub/ansible
This commit is contained in:
fencl
2025-10-05 16:45:20 +02:00
parent cadc296a1f
commit f08dc68e20

View File

@@ -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 }}"