16:30
This commit is contained in:
@@ -111,22 +111,15 @@
|
|||||||
nb_ok_line: "{{ nb_ok_line }}"
|
nb_ok_line: "{{ nb_ok_line }}"
|
||||||
|
|
||||||
# --- Detect "cloud vs NetBox (before update) was different"
|
# --- Detect "cloud vs NetBox (before update) was different"
|
||||||
# Match any of the script's change-indicator lines:
|
# Trigger on any of these lines from the Python script:
|
||||||
# - "IP: moving ..."
|
# "IP: moving ...", "IP: create new ...", "IP: pruning stale ..."
|
||||||
# - "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:
|
||||||
nb_lines: >-
|
out: "{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) }}"
|
||||||
{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) | split('\n') | map('trim') | list }}
|
|
||||||
change_lines: >-
|
change_lines: >-
|
||||||
{{
|
{{ out | regex_findall('(?:^|\\n)(IP: (?:moving|create new|pruning stale)[^\\n]*)', multiline=True) }}
|
||||||
nb_lines
|
|
||||||
| select('match', '^IP:\\s+(moving|create new|pruning stale)\\b')
|
|
||||||
| list
|
|
||||||
}}
|
|
||||||
set_fact:
|
set_fact:
|
||||||
nb_ip_changed: "{{ (change_lines | length) > 0 }}"
|
nb_ip_changed: "{{ (change_lines | length) > 0 }}"
|
||||||
nb_change_lines: "{{ change_lines }}"
|
nb_change_lines: "{{ change_lines }}"
|
||||||
@@ -141,7 +134,6 @@
|
|||||||
- "OK line: {{ nb_ok_line | default('<none>') }}"
|
- "OK line: {{ nb_ok_line | default('<none>') }}"
|
||||||
- "Parsed nb_ip={{ nb_ip | default('<n/a>') }}"
|
- "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"
|
||||||
when:
|
when:
|
||||||
|
|||||||
Reference in New Issue
Block a user