16:16
This commit is contained in:
@@ -79,13 +79,16 @@
|
|||||||
- "{{ (nb_preflight.stderr_lines | default(['<no stderr>'])) }}"
|
- "{{ (nb_preflight.stderr_lines | default(['<no stderr>'])) }}"
|
||||||
- "raw stdout (joined): {{ nb_preflight.stdout | default('') | trim }}"
|
- "raw stdout (joined): {{ nb_preflight.stdout | default('') | trim }}"
|
||||||
|
|
||||||
# --- Parse the OK line for reuse (device/ip/fw/etc.) ---
|
|
||||||
- name: "NB preflight | Parse OK line"
|
# --- Parse the OK line robustly (line-by-line) ---
|
||||||
|
- name: "NB preflight | Parse OK line (robust)"
|
||||||
when: nb_script.stat.exists
|
when: nb_script.stat.exists
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
vars:
|
vars:
|
||||||
|
nb_lines: >-
|
||||||
|
{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) | split('\n') | map('trim') | list }}
|
||||||
nb_ok_line: >-
|
nb_ok_line: >-
|
||||||
{{ (nb_preflight.stdout | default('') | regex_findall('^OK\\s+.*$', multiline=True)) | last | default('') }}
|
{{ (nb_lines | select('match', '^OK\\s+') | list | last | default('')) }}
|
||||||
nb_groups: >-
|
nb_groups: >-
|
||||||
{{ (nb_ok_line | regex_findall('^OK\\s+(\\S+)\\s+ip=([^\\s]+)\\s+fw=([^\\s]+)\\s+node=([^\\s]+)\\s+sector=([^\\s]+)\\s+small=([^\\s]+)')) | first | default([]) }}
|
{{ (nb_ok_line | regex_findall('^OK\\s+(\\S+)\\s+ip=([^\\s]+)\\s+fw=([^\\s]+)\\s+node=([^\\s]+)\\s+sector=([^\\s]+)\\s+small=([^\\s]+)')) | first | default([]) }}
|
||||||
set_fact:
|
set_fact:
|
||||||
@@ -98,13 +101,16 @@
|
|||||||
nb_small: "{{ nb_groups[5] | default('') }}"
|
nb_small: "{{ nb_groups[5] | default('') }}"
|
||||||
nb_ok_line: "{{ nb_ok_line }}"
|
nb_ok_line: "{{ nb_ok_line }}"
|
||||||
|
|
||||||
# --- Heuristic for "cloud IP different from NetBox before update" ---
|
# --- Detect "was different before update" via the script's own signal line ---
|
||||||
# We detect this via the script's chatty line: "IP: moving <old-ip> from iface=... -> ..."
|
|
||||||
- name: "NB preflight | Detect whether IP changed (cloud vs prior NetBox)"
|
- name: "NB preflight | Detect whether IP changed (cloud vs prior NetBox)"
|
||||||
when: nb_script.stat.exists
|
when: nb_script.stat.exists
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
vars:
|
||||||
|
nb_lines: >-
|
||||||
|
{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) | split('\n') | map('trim') | list }}
|
||||||
set_fact:
|
set_fact:
|
||||||
nb_ip_changed: "{{ (nb_preflight.stdout | default('')) is search('^IP:\\s+moving\\s+[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\s+from\\s+iface=', multiline=True) }}"
|
nb_ip_changed: "{{ (nb_lines | select('match', '^IP:\\s+moving\\s+[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\s+from\\s+iface=') | list | length) > 0 }}"
|
||||||
|
|
||||||
|
|
||||||
- name: "NB preflight | Verdict"
|
- name: "NB preflight | Verdict"
|
||||||
when: nb_script.stat.exists
|
when: nb_script.stat.exists
|
||||||
|
|||||||
Reference in New Issue
Block a user