16:34
This commit is contained in:
@@ -110,19 +110,21 @@
|
|||||||
nb_small: "{{ nb_kv.get('small', '') }}"
|
nb_small: "{{ nb_kv.get('small', '') }}"
|
||||||
nb_ok_line: "{{ nb_ok_line }}"
|
nb_ok_line: "{{ nb_ok_line }}"
|
||||||
|
|
||||||
# --- Detect "cloud vs NetBox (before update) was different"
|
|
||||||
# Trigger on any of these lines from the Python script:
|
# --- Detect "cloud vs NetBox (before update) was different" (regex-free, robust)
|
||||||
# "IP: moving ...", "IP: create new ...", "IP: pruning stale ..."
|
|
||||||
- name: "NB preflight | Detect whether IP changed (pre-update)"
|
- name: "NB preflight | Detect whether IP changed (pre-update)"
|
||||||
when: nb_script.stat.exists
|
when: nb_script.stat.exists
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
vars:
|
vars:
|
||||||
out: "{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) }}"
|
out: "{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) }}"
|
||||||
change_lines: >-
|
reason: >-
|
||||||
{{ out | regex_findall('(?:^|\\n)(IP: (?:moving|create new|pruning stale)[^\\n]*)', multiline=True) }}
|
{%- if 'IP: moving ' in out -%}moving
|
||||||
|
{%- elif 'IP: create new ' in out -%}create new
|
||||||
|
{%- elif 'IP: pruning stale ' in out -%}pruning stale
|
||||||
|
{%- else -%}none{%- endif -%}
|
||||||
set_fact:
|
set_fact:
|
||||||
nb_ip_changed: "{{ (change_lines | length) > 0 }}"
|
nb_ip_changed: "{{ reason != 'none' }}"
|
||||||
nb_change_lines: "{{ change_lines }}"
|
nb_change_reason: "{{ reason }}"
|
||||||
|
|
||||||
- name: "NB preflight | Verdict"
|
- name: "NB preflight | Verdict"
|
||||||
when: nb_script.stat.exists
|
when: nb_script.stat.exists
|
||||||
@@ -130,9 +132,10 @@
|
|||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg:
|
msg:
|
||||||
- "NB preflight verdict: {{ 'IP CHANGED (will requeue)' if nb_ip_changed else 'IP SAME (continue)' }}"
|
- "NB preflight verdict: {{ 'IP CHANGED (will requeue)' if nb_ip_changed else 'IP SAME (continue)' }}"
|
||||||
- "Change lines matched: {{ (nb_change_lines | default([])) | join(' | ') if nb_ip_changed else '<none>' }}"
|
- "Reason: {{ nb_change_reason }}"
|
||||||
- "OK line: {{ nb_ok_line | default('<none>') }}"
|
|
||||||
- "Parsed nb_ip={{ nb_ip | default('<n/a>') }}"
|
|
||||||
|
|
||||||
|
|
||||||
# --- If IP changed → publish a 3s delayed 'sot-updater' task and stop this host ---
|
# --- If IP changed → publish a 3s delayed 'sot-updater' task and stop this host ---
|
||||||
- name: "NB preflight | Publish delayed requeue (3s) and stop"
|
- name: "NB preflight | Publish delayed requeue (3s) and stop"
|
||||||
|
|||||||
Reference in New Issue
Block a user