This commit is contained in:
2025-11-04 18:06:08 +02:00
parent fd2268a425
commit 9c7ad84e8d

View File

@@ -109,21 +109,15 @@
nb_small: "{{ nb_kv.get('small', '') }}" nb_small: "{{ nb_kv.get('small', '') }}"
nb_ok_line: "{{ nb_ok_line }}" nb_ok_line: "{{ nb_ok_line }}"
# --- Extract upgrade_cmd from nb_onedevice_update.py output --- # --- Extract upgrade_cmd from nb_onedevice_update.py output (regex, robust) ---
- name: "NB preflight | Capture upgrade_cmd from stdout" - name: "NB preflight | Capture upgrade_cmd from stdout"
when: nb_script.stat.exists when: nb_script.stat.exists
delegate_to: localhost delegate_to: localhost
vars: vars:
up_line: >- stdout_clean: "{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) }}"
{{ # Find all lines like: NB: upgrade_cmd=...
( up_matches: "{{ stdout_clean | regex_findall('(?mi)^NB:\\s*upgrade_cmd=\\s*(.*)$') }}"
(nb_preflight.stdout | default('') | regex_replace('\r','')) up_val_raw: "{{ (up_matches | first | default('')) | trim }}"
| split('\n') | map('trim')
)
| select('search', '^NB:\\s+upgrade_cmd=')
| list | last | default('')
}}
up_val_raw: "{{ up_line | regex_replace('^NB:\\s+upgrade_cmd=', '') | trim }}"
# Normalize None/null/empty to '' ; otherwise keep verbatim # Normalize None/null/empty to '' ; otherwise keep verbatim
up_val_clean: >- up_val_clean: >-
{{ {{
@@ -137,7 +131,7 @@
delegate_to: localhost delegate_to: localhost
ansible.builtin.debug: ansible.builtin.debug:
msg: msg:
- "upgrade_cmd line: {{ up_line | default('<none>') }}" - "upgrade_cmd raw match: '{{ (up_matches | first | default('<none>')) }}'"
- "upgrade_cmd parsed: '{{ nb_upgrade_cmd | default('') }}' (len={{ (nb_upgrade_cmd | default('')) | length }})" - "upgrade_cmd parsed: '{{ nb_upgrade_cmd | default('') }}' (len={{ (nb_upgrade_cmd | default('')) | length }})"