This commit is contained in:
2026-01-20 06:41:47 +02:00
parent 0b5f0b35a1
commit 90d38e8fd0

View File

@@ -13,39 +13,40 @@
hosts: all
gather_facts: no
tasks:
- name: "Wrapper | Debug where iponly facts live"
- name: "Wrapper | Extract nb_ip from nb_onedevice_update.py stdout"
vars:
_out: "{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) }}"
_ok_line: "{{ (_out.split('\n') | map('trim') | select('match','^OK\\s+') | list | last | default('')) }}"
_ip: "{{ _ok_line | regex_search('(?:^|\\s)ip=([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(?:\\s|$)', '\\1') | default('') }}"
set_fact:
wrapper_ok_line: "{{ _ok_line }}"
wrapper_nb_ip: "{{ _ip | trim }}"
- name: "Wrapper | Debug extracted values"
ansible.builtin.debug:
msg:
- "host nb_ok={{ nb_ok | default('UNDEF') }}, nb_ip={{ nb_ip | default('UNDEF') }}"
- "localhost nb_ok={{ hostvars['localhost'].nb_ok | default('UNDEF') }}, nb_ip={{ hostvars['localhost'].nb_ip | default('UNDEF') }}"
- "wrapper_ok_line='{{ wrapper_ok_line }}'"
- "wrapper_nb_ip='{{ wrapper_nb_ip }}'"
- name: "Wrapper | Assert iponly succeeded"
- name: "Wrapper | Assert IP extracted successfully"
ansible.builtin.assert:
that:
- nb_script is defined
- nb_script.stat.exists | default(false)
- nb_ok | default(false)
- (nb_ip | default('') | trim) not in ('', 'NONE', 'null')
- (wrapper_ok_line | length) > 0
- (wrapper_nb_ip | length) > 0
fail_msg: >-
Wrapper stop: iponly did not produce a usable IP.
nb_ok={{ nb_ok | default('UNDEF') }},
nb_ip='{{ nb_ip | default('UNDEF') }}'
Wrapper stop: could not extract IP from nb_onedevice_update.py output.
ok_line='{{ wrapper_ok_line | default('') }}'
stdout_tail={{ (nb_preflight.stdout_lines | default([]))[-12:] }}
- name: "Wrapper | Override ansible_host to refreshed IP ({{ nb_ip }})"
- name: "Wrapper | Override ansible_host to refreshed IP ({{ wrapper_nb_ip }})"
set_fact:
ansible_host: "{{ nb_ip | trim }}"
ansible_host: "{{ wrapper_nb_ip }}"
- name: "Wrapper | Reset SSH connection context (ensure new ansible_host is used)"
meta: reset_connection
- name: "Wrapper | Debug effective target"
debug:
msg:
- "Effective ansible_host={{ ansible_host }}"
- "nb_ip={{ nb_ip }}"
- import_playbook: sot-updater.yml