From b6bc15fd17de01d7b71a67e447968ac41b32c174 Mon Sep 17 00:00:00 2001 From: pavel Date: Wed, 22 Oct 2025 23:36:21 +0300 Subject: [PATCH] 2336 --- files/ansible-playbooks/update-indoor.yml | 43 +++++++---------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/files/ansible-playbooks/update-indoor.yml b/files/ansible-playbooks/update-indoor.yml index fd4f97f..e864ce3 100644 --- a/files/ansible-playbooks/update-indoor.yml +++ b/files/ansible-playbooks/update-indoor.yml @@ -482,19 +482,24 @@ msg: "DEV2 firmux={{ (dev2_firmux.stdout | default('')) | trim }}" # ---------------------------- Normalize rebootin early (HOURS) ---------------------------- - # Accept: "", "now", "immediate", numeric (4), numeric string ("4"), or "4h" + # Strict: rebootin is integer HOURS only. Always add +20s grace to the schedule. - - name: Normalize rebootin (strict hours → seconds/minutes) + - name: Normalize rebootin (strict hours → base seconds/minutes) delegate_to: localhost ansible.builtin.set_fact: - reboot_hours: "{{ (rebootin | default('') | string) | trim | int }}" - reboot_seconds: "{{ ((rebootin | default('') | string) | trim | int) * 3600 }}" - reboot_minutes: "{{ ((rebootin | default('') | string) | trim | int) * 60 }}" - _reboot_seconds: "{{ reboot_seconds | int }}" - _reboot_minutes: "{{ reboot_minutes | int }}" + reboot_hours: "{{ (rebootin | default('') | string | trim | int) }}" + reboot_seconds: "{{ (rebootin | default('') | string | trim | int) * 3600 }}" + reboot_minutes: "{{ (rebootin | default('') | string | trim | int) * 60 }}" reboot_requested: true + _reboot_requested: true - + - name: Compute reboot delay (+20s grace) and mirror underscore vars + delegate_to: localhost + ansible.builtin.set_fact: + reboot_delay_seconds: "{{ (reboot_seconds | int) + 20 }}" + reboot_delay_minutes: "{{ (((reboot_seconds | int) + 20) // 60) | int }}" + _reboot_seconds: "{{ (reboot_seconds | int) + 20 }}" + _reboot_minutes: "{{ (((reboot_seconds | int) + 20) // 60) | int }}" - name: Debug reboot normalization detail delegate_to: localhost @@ -505,30 +510,12 @@ - "reboot_seconds={{ reboot_seconds }}" - "reboot_minutes={{ reboot_minutes }}" - - name: Warn if rebootin was not provided by consumer (debug only) when: (rebootin | default('') | string | trim) == '' delegate_to: localhost ansible.builtin.debug: msg: "WARNING: rebootin is empty or missing. Consumer likely did not pass -e rebootin=." - # Compute reboot flags and *final* seconds. - # Rule: now/empty/0 -> 20s grace; hours>0 -> hours*3600 (no extra 20s). - - - name: Compute reboot delay (add 20s grace) - delegate_to: localhost - ansible.builtin.set_fact: - reboot_delay_seconds: "{{ (reboot_seconds | int) + 20 }}" - reboot_delay_minutes: "{{ ((reboot_seconds + 20) / 60) | int }}" - - - - # Derive minutes from seconds - - name: Derive reboot minutes from seconds - delegate_to: localhost - ansible.builtin.set_fact: - _reboot_minutes: "{{ ((_reboot_seconds | int) // 60) if (_reboot_seconds | int) > 0 else 0 }}" - - name: Debug reboot plan summary delegate_to: localhost ansible.builtin.debug: @@ -1043,8 +1030,6 @@ ansible.builtin.set_fact: expected_fw_core: "{{ (image_filename | regex_search('[0-9]+\\.[0-9]+\\.[0-9]+-r[0-9]+')) | default('', true) }}" - - - name: Debug derived expected target_version for checker delegate_to: localhost ansible.builtin.debug: @@ -1069,7 +1054,6 @@ when: au_delay_sec is defined delegate_to: localhost - - name: Debug after-upgrade plan (routing + delay + version) ansible.builtin.debug: msg: @@ -1085,7 +1069,6 @@ msg: "{{ afterupgrade_payload | to_json }}" when: afterupgrade_payload is defined - - name: Publish delayed after-upgrade check (headers.x-delay) to holding exchange ansible.builtin.uri: url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost | urlencode }}/{{ 'deviceconfig.delayed' | urlencode }}/publish"