diff --git a/files/ansible-playbooks/sot-updater.yml b/files/ansible-playbooks/sot-updater.yml index a1e1762..368a392 100644 --- a/files/ansible-playbooks/sot-updater.yml +++ b/files/ansible-playbooks/sot-updater.yml @@ -111,22 +111,15 @@ nb_ok_line: "{{ nb_ok_line }}" # --- Detect "cloud vs NetBox (before update) was different" - # Match any of the script's change-indicator lines: - # - "IP: moving ..." - # - "IP: create new ..." - # - "IP: pruning stale ..." + # Trigger on any of these lines from the Python script: + # "IP: moving ...", "IP: create new ...", "IP: pruning stale ..." - name: "NB preflight | Detect whether IP changed (pre-update)" when: nb_script.stat.exists delegate_to: localhost vars: - nb_lines: >- - {{ (nb_preflight.stdout | default('') | regex_replace('\r','')) | split('\n') | map('trim') | list }} + out: "{{ (nb_preflight.stdout | default('') | regex_replace('\r','')) }}" change_lines: >- - {{ - nb_lines - | select('match', '^IP:\\s+(moving|create new|pruning stale)\\b') - | list - }} + {{ out | regex_findall('(?:^|\\n)(IP: (?:moving|create new|pruning stale)[^\\n]*)', multiline=True) }} set_fact: nb_ip_changed: "{{ (change_lines | length) > 0 }}" nb_change_lines: "{{ change_lines }}" @@ -141,7 +134,6 @@ - "OK line: {{ nb_ok_line | default('') }}" - "Parsed nb_ip={{ nb_ip | default('') }}" - # --- If IP changed → publish a 3s delayed 'sot-updater' task and stop this host --- - name: "NB preflight | Publish delayed requeue (3s) and stop" when: