This commit is contained in:
2025-10-22 17:43:58 +03:00
parent 0941f3ab3f
commit b565fa781a

View File

@@ -471,7 +471,8 @@
msg: "DEV2 firmux={{ (dev2_firmux.stdout | default('')) | trim }}"
# ---------------------------- Normalize rebootin early (HOURS) ----------------------------
- name: Normalize 'rebootin' (detect 'now' or integer HOURS)
# Normalize 'rebootin' (detect 'now' or integer HOURS)
- name: Normalize rebootin detect now or integer HOURS
delegate_to: localhost
ansible.builtin.set_fact:
_reboot_raw: "{{ rebootin | default('') | string | trim | lower }}"
@@ -483,20 +484,21 @@
else (rebootin | int if ((rebootin | default('') | string | trim) is match('^\\d+$')) else -1)
}}
- name: Compute reboot flags requested and seconds
# Compute reboot flags and *final* seconds value with the 20s grace rule
# Rule: now/empty -> 20s; integer <=0 -> 20s; integer >0 -> hours*3600
- name: Compute reboot flags requested and seconds with 20s grace
delegate_to: localhost
ansible.builtin.set_fact:
_reboot_requested: "{{ _reboot_is_now or _reboot_is_int }}"
_reboot_seconds: >-
{{
20
if (_reboot_requested | default(false)) and ((_reboot_hours | int) <= 0)
else
(((_reboot_hours | int) * 3600))
if (_reboot_requested | default(false))
else 0
if _reboot_is_now
else (20 if ((_reboot_is_int | bool) and ((_reboot_hours | int) <= 0))
else ((_reboot_hours | int) * 3600))
}}
# Derive minutes from seconds
- name: Derive reboot minutes from seconds
delegate_to: localhost
ansible.builtin.set_fact:
@@ -521,7 +523,7 @@
Indoor: Dev2 is reachable, starting update.
image={{ image_filename }}, md5={{ image_md5 }},
firmux={{ (dev2_firmux.stdout | default('unknown')) | trim }},
reboot={{ 'in ' ~ (_reboot_seconds | int) ~ ' seconds' if (_reboot_is_now and (_reboot_minutes | int) == 0) else (rebootin | default('') | trim) }}
reboot={{ 'in ' ~ (_reboot_seconds | int) ~ ' seconds' if (_reboot_requested | default(false)) else 'not requested' }}
when: dev2_passfile_used != "NONE"
delegate_to: localhost
@@ -1097,8 +1099,8 @@
- "active_before={{ (dev2_active_before.stdout | default('NA')) | trim }}"
- "active_after={{ (dev2_active_after.stdout | default('NA')) | trim }}"
- "reboot_requested={{ _reboot_requested | default(false) }}"
- "reboot_delay_minutes={{ (_reboot_minutes | int) if (_reboot_requested | default(false)) else 'NA' }}"
- "reboot_delay_seconds={{ (_reboot_seconds | int) if (_reboot_requested | default(false)) else 'NA' }}"
- "reboot_delay_seconds={{ _reboot_seconds | int if (_reboot_requested | default(false)) else 'NA' }}"
- "reboot_delay_minutes={{ _reboot_minutes | int if (_reboot_requested | default(false)) else 'NA' }}"
- "reboot_applied={{ (dev2_reboot_sched is defined and dev2_reboot_sched.rc is defined and dev2_reboot_sched.rc == 0) | default(false) }}"
- "prep_blocked={{ _prep_blocked | default(false) }}"
- "blocked={{ _blocked | default(false) }}"