This commit is contained in:
2025-10-24 10:06:31 +03:00
parent 9797e305ae
commit 397e3409cb

View File

@@ -49,14 +49,18 @@
msg: msg:
- "Dev1 banner raw: {{ (dev1_banner.stdout | default('') | trim) | regex_replace('\\n',' ') }}" - "Dev1 banner raw: {{ (dev1_banner.stdout | default('') | trim) | regex_replace('\\n',' ') }}"
# Keep the agreed format EXACTLY "X.Y.Z rev NNNN" (no timestamp). # ***** FIXED: Strictly extract ONLY "X.Y.Z rev NNNN" from the banner *****
- name: Dev1 | Extract 'X.Y.Z rev NNNN' from banner (no timestamp) # 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 exact 'X.Y.Z rev NNNN' (no timestamp)
delegate_to: localhost delegate_to: localhost
set_fact: set_fact:
dev1_fw_clean: >- dev1_fw_clean: >-
{{ {{
(dev1_banner.stdout | default('') | trim) (
| regex_replace('^(.+?[Rr][Ee][Vv]\\.??\\s*[0-9]+).*$', '\\1') (dev1_banner.stdout | default('') | trim)
| regex_findall('([0-9]+\\.[0-9]+\\.[0-9]+\\s+[Rr][Ee][Vv]\\.??\\s*\\d+)')
) | first | default('')
}} }}
- name: Dev1 | Debug normalized fw string to be published - name: Dev1 | Debug normalized fw string to be published
@@ -404,7 +408,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