This commit is contained in:
2025-10-24 10:29:21 +03:00
parent 9e9acff4c1
commit e84e26b393

View File

@@ -32,7 +32,7 @@
tasks: tasks:
# ───────────────────────── Progress: start ───────────────────────── # ───────────────────────── Progress: start ─────────────────────────
- name: ⚙️ Start | Device processing begins (Dev1 phase) - name: "⚙️ Start | Device processing begins (Dev1 phase)"
debug: debug:
msg: msg:
- "Device: {{ inventory_hostname }}" - "Device: {{ inventory_hostname }}"
@@ -49,19 +49,11 @@
msg: msg:
- "Dev1 banner raw: {{ (dev1_banner.stdout | default('') | trim) | regex_replace('\\n',' ') }}" - "Dev1 banner raw: {{ (dev1_banner.stdout | default('') | trim) | regex_replace('\\n',' ') }}"
# ***** FIXED: Strictly extract ONLY "X.Y.Z rev NNNN" from the banner ***** # Extract exactly "X.Y.Z rev NNNN" by dropping anything after the pipe
# This grabs the first occurrence of "<digits>.<digits>.<digits> rev <digits>"
# and ignores any trailing timestamp like " | 2025-09-25 07:06:10".
- name: Dev1 | Extract 'X.Y.Z rev NNNN' by removing trailing timestamp - name: Dev1 | Extract 'X.Y.Z rev NNNN' by removing trailing timestamp
delegate_to: localhost delegate_to: localhost
set_fact: set_fact:
dev1_fw_clean: >- dev1_fw_clean: "{{ (dev1_banner.stdout | default('') | trim) | regex_replace('\\s*\\|.*$', '') }}"
{{
(dev1_banner.stdout | default('') | trim)
| regex_replace('\\s*\\|.*$', '') # drop " | 2025-09-25 ..." and anything after
}}
- name: Dev1 | Debug normalized fw string to be published - name: Dev1 | Debug normalized fw string to be published
delegate_to: localhost delegate_to: localhost
@@ -69,15 +61,11 @@
msg: msg:
- "Dev1 fw_version (clean): {{ dev1_fw_clean }}" - "Dev1 fw_version (clean): {{ dev1_fw_clean }}"
- name: Dev2 | Build payload preview string # Build payload preview for Dev1 (so the next debug is defined)
when: - name: Dev1 | Build payload preview string
- dev2_passfile_used is defined
- dev2_passfile_used != "NONE"
- indoor_fw_norm is defined
- (indoor_fw_norm | length) > 0
delegate_to: localhost delegate_to: localhost
set_fact: set_fact:
dev2_payload_preview: >- dev1_payload_preview: >-
{{ {{
{ {
"properties": {"content_type": "application/json"}, "properties": {"content_type": "application/json"},
@@ -85,15 +73,15 @@
"payload": ({ "payload": ({
"inscope_device": (ansible_hostname | default(inventory_hostname)), "inscope_device": (ansible_hostname | default(inventory_hostname)),
"task_name": "custom_field_set", "task_name": "custom_field_set",
"task_add1": "indoor_fwver", "task_add1": "fw_version",
"task_result": indoor_fw_norm # ← FIXED "task_result": dev1_fw_clean
} | to_json), } | to_json),
"payload_encoding": "string" "payload_encoding": "string"
} | to_json } | to_json
}} }}
- name: Dev1 | Debug EXACT publish body (payload preview) - name: Dev1 | Debug EXACT publish body (payload preview)
when: dev1_payload_preview is defined
delegate_to: localhost delegate_to: localhost
debug: debug:
var: dev1_payload_preview var: dev1_payload_preview
@@ -128,7 +116,7 @@
msg: msg:
- "Dev1 publish response: {{ dev1_publish_resp.json | default(dev1_publish_resp) }}" - "Dev1 publish response: {{ dev1_publish_resp.json | default(dev1_publish_resp) }}"
- name: ✅ Progress | Completed Dev1, moving to tunnel & Dev2 phase - name: "✅ Progress | Completed Dev1, moving to tunnel & Dev2 phase"
debug: debug:
msg: msg:
- "Device: {{ inventory_hostname }}" - "Device: {{ inventory_hostname }}"
@@ -251,7 +239,7 @@
ansible.builtin.meta: end_host ansible.builtin.meta: end_host
when: nc_probe.rc != 0 when: nc_probe.rc != 0
- name: ✅ Progress | Tunnel OK, proceeding to Dev2 auth and reads - name: "✅ Progress | Tunnel OK, proceeding to Dev2 auth and reads"
debug: debug:
msg: msg:
- "Device: {{ inventory_hostname }}" - "Device: {{ inventory_hostname }}"
@@ -396,9 +384,10 @@
msg: msg:
- "Dev2 indoor_fw_norm: {{ indoor_fw_norm }}" - "Dev2 indoor_fw_norm: {{ indoor_fw_norm }}"
# Build payload preview (exact string). # Build payload preview (exact string) — single, corrected task
- name: Dev2 | Build payload preview string - name: Dev2 | Build payload preview string
when: when:
- dev2_passfile_used is defined
- dev2_passfile_used != "NONE" - dev2_passfile_used != "NONE"
- indoor_fw_norm is defined - indoor_fw_norm is defined
- (indoor_fw_norm | length) > 0 - (indoor_fw_norm | length) > 0
@@ -413,7 +402,7 @@
"inscope_device": (ansible_hostname | default(inventory_hostname)), "inscope_device": (ansible_hostname | default(inventory_hostname)),
"task_name": "custom_field_set", "task_name": "custom_field_set",
"task_add1": "indoor_fwver", "task_add1": "indoor_fwver",
"task_result': indoor_fw_norm "task_result": indoor_fw_norm
} | to_json), } | to_json),
"payload_encoding": "string" "payload_encoding": "string"
} | to_json } | to_json
@@ -463,7 +452,7 @@
- "Dev2 publish response: {{ dev2_publish_resp.json | default(dev2_publish_resp) }}" - "Dev2 publish response: {{ dev2_publish_resp.json | default(dev2_publish_resp) }}"
post_tasks: post_tasks:
- name: ✅ Progress | Finishing up (cleanup) - name: "✅ Progress | Finishing up (cleanup)"
debug: debug:
msg: msg:
- "Cleanup phase: closing ControlMaster & removing temp IP" - "Cleanup phase: closing ControlMaster & removing temp IP"
@@ -498,7 +487,7 @@
- "stdout={{ (del_ip.stdout | default('')) | trim }}" - "stdout={{ (del_ip.stdout | default('')) | trim }}"
- "stderr={{ (del_ip.stderr | default('')) | trim }}" - "stderr={{ (del_ip.stderr | default('')) | trim }}"
- name: ✅ Progress | Completed device processing - name: "✅ Progress | Completed device processing"
debug: debug:
msg: msg:
- "Device: {{ inventory_hostname }}" - "Device: {{ inventory_hostname }}"