2211
This commit is contained in:
@@ -482,17 +482,24 @@
|
|||||||
msg: "DEV2 firmux={{ (dev2_firmux.stdout | default('')) | trim }}"
|
msg: "DEV2 firmux={{ (dev2_firmux.stdout | default('')) | trim }}"
|
||||||
|
|
||||||
# ---------------------------- Normalize rebootin early (HOURS) ----------------------------
|
# ---------------------------- Normalize rebootin early (HOURS) ----------------------------
|
||||||
# Normalize 'rebootin' (detect 'now' or integer HOURS)
|
# Accept: "", "now", "immediate", numeric (4), numeric string ("4"), or "4h"
|
||||||
- name: Normalize rebootin detect now or integer HOURS
|
- name: Normalize rebootin detect now or integer HOURS
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
_reboot_raw: "{{ rebootin | default('') | string | trim | lower }}"
|
_reboot_raw: "{{ rebootin | default('') | string | trim | lower }}"
|
||||||
_reboot_is_now: "{{ (rebootin | default('') | string | trim | lower) in ['', 'now', 'immediate'] }}"
|
_reboot_is_now: "{{ (rebootin | default('') | string | trim | lower) in ['', 'now', 'immediate'] }}"
|
||||||
_reboot_is_int: "{{ (rebootin | default('') | string | trim) is match('^\\d+$') }}"
|
_reboot_is_numtype: "{{ (rebootin | type_debug) in ['int','float'] }}"
|
||||||
|
_reboot_is_digitstr: "{{ (rebootin | default('') | string | trim) is match('^\\d+$') }}"
|
||||||
|
_reboot_is_hsuffix: "{{ (rebootin | default('') | string | trim | lower) is match('^\\d+h$') }}"
|
||||||
_reboot_hours: >-
|
_reboot_hours: >-
|
||||||
{{
|
{{
|
||||||
0 if ((rebootin | default('') | string | trim | lower) in ['', 'now', 'immediate'])
|
0
|
||||||
else (rebootin | int if ((rebootin | default('') | string | trim) is match('^\\d+$')) else -1)
|
if ((rebootin | default('') | string | trim | lower) in ['', 'now', 'immediate'])
|
||||||
|
else ( (rebootin | int)
|
||||||
|
if ((rebootin | type_debug) in ['int','float'])
|
||||||
|
else ( (_reboot_raw | regex_replace('h$', '') | int)
|
||||||
|
if (_reboot_is_digitstr or _reboot_is_hsuffix)
|
||||||
|
else -1))
|
||||||
}}
|
}}
|
||||||
|
|
||||||
- name: Debug reboot normalization detail
|
- name: Debug reboot normalization detail
|
||||||
@@ -501,7 +508,9 @@
|
|||||||
msg:
|
msg:
|
||||||
- "_reboot_raw={{ _reboot_raw | default('UNSET') }}"
|
- "_reboot_raw={{ _reboot_raw | default('UNSET') }}"
|
||||||
- "_reboot_is_now={{ _reboot_is_now | default('UNSET') }}"
|
- "_reboot_is_now={{ _reboot_is_now | default('UNSET') }}"
|
||||||
- "_reboot_is_int={{ _reboot_is_int | default('UNSET') }}"
|
- "_reboot_is_numtype={{ _reboot_is_numtype | default('UNSET') }}"
|
||||||
|
- "_reboot_is_digitstr={{ _reboot_is_digitstr | default('UNSET') }}"
|
||||||
|
- "_reboot_is_hsuffix={{ _reboot_is_hsuffix | default('UNSET') }}"
|
||||||
- "_reboot_hours={{ _reboot_hours | default('UNSET') }}"
|
- "_reboot_hours={{ _reboot_hours | default('UNSET') }}"
|
||||||
|
|
||||||
- name: Warn if rebootin was not provided by consumer (debug only)
|
- name: Warn if rebootin was not provided by consumer (debug only)
|
||||||
@@ -510,19 +519,17 @@
|
|||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "WARNING: rebootin is empty or missing. Consumer likely did not pass -e rebootin=<hours>."
|
msg: "WARNING: rebootin is empty or missing. Consumer likely did not pass -e rebootin=<hours>."
|
||||||
|
|
||||||
|
# Compute reboot flags and *final* seconds.
|
||||||
# Compute reboot flags and *final* seconds value with the 20s grace rule
|
# Rule: now/empty/0 -> 20s grace; hours>0 -> hours*3600 (no extra 20s).
|
||||||
# Rule: now/empty -> 20s; integer <=0 -> 20s; integer >0 -> hours*3600
|
- name: Compute reboot flags requested and seconds with proper conversion
|
||||||
- name: Compute reboot flags requested and seconds with 20s grace
|
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
_reboot_requested: "{{ _reboot_is_now or _reboot_is_int }}"
|
_reboot_requested: "{{ _reboot_is_now or (_reboot_hours | int) >= 0 }}"
|
||||||
_reboot_seconds: >-
|
_reboot_seconds: >-
|
||||||
{{
|
{{
|
||||||
20
|
20
|
||||||
if _reboot_is_now
|
if (_reboot_is_now or ((_reboot_hours | int) == 0))
|
||||||
else (20 if ((_reboot_is_int | bool) and ((_reboot_hours | int) <= 0))
|
else ((_reboot_hours | int) * 3600)
|
||||||
else ((_reboot_hours | int) * 3600))
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
# Derive minutes from seconds
|
# Derive minutes from seconds
|
||||||
@@ -531,7 +538,6 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
_reboot_minutes: "{{ ((_reboot_seconds | int) // 60) if (_reboot_seconds | int) > 0 else 0 }}"
|
_reboot_minutes: "{{ ((_reboot_seconds | int) // 60) if (_reboot_seconds | int) > 0 else 0 }}"
|
||||||
|
|
||||||
|
|
||||||
- name: Debug reboot plan summary
|
- name: Debug reboot plan summary
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
|
|||||||
Reference in New Issue
Block a user