# sot-updater-wrapper.yml # Single nbplay invocation: # Phase 1: Cloud -> NetBox sync (via sot-updater-iponly.yml in wrapper mode) # Phase 2: Refresh ansible_host from nb_ip, reset_connection # Phase 3: Run full sot-updater-current.yml - import_playbook: sot-updater-iponly.yml vars: sot_wrapper_mode: true - name: Phase 2 | Refresh in-memory target IP after iponly hosts: all gather_facts: no tasks: - name: "Wrapper | Extract nb_ip from nb_onedevice_update.py stdout" vars: _lines: "{{ (nb_preflight.stdout_lines | default([])) | map('regex_replace','\r','') | map('trim') | list }}" _ok_line: "{{ (_lines | 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: - "wrapper_ok_line='{{ wrapper_ok_line }}'" - "wrapper_nb_ip='{{ wrapper_nb_ip }}'" - name: "Wrapper | Assert IP extracted successfully" ansible.builtin.assert: that: - nb_script is defined - nb_script.stat.exists | default(false) - (wrapper_ok_line | length) > 0 - (wrapper_nb_ip | length) > 0 fail_msg: >- 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 ({{ wrapper_nb_ip }})" set_fact: ansible_host: "{{ wrapper_nb_ip }}" - name: "Wrapper | Reset SSH connection context (ensure new ansible_host is used)" meta: reset_connection - import_playbook: sot-updater.yml