This commit is contained in:
2026-02-25 18:00:00 +02:00
parent a289bfc167
commit 0b784346f7

View File

@@ -279,6 +279,7 @@
# ----------------------- NetBox baseline (for delta compare) -----------------------
- name: NB baseline | Init baseline facts
delegate_to: localhost
set_fact:
@@ -287,35 +288,33 @@
nb_custom_fields_current: {}
changed_when: false
- name: NB baseline | Read id and custom_fields (fields)
when:
- (netbox_url | default('') | length) > 0
- (netbox_token | default('') | length) > 0
# NOTE: this task must exist above (keep your existing one):
# - name: NB baseline | Read id and custom_fields (fields)
# delegate_to: localhost
# uri: ...
- name: NB baseline | Set baseline facts (best effort; do not fail play)
delegate_to: localhost
uri:
url: "{{ netbox_url }}/api/dcim/devices/?name={{ inventory_hostname|urlencode }}&fields=id,custom_fields&limit=1"
method: GET
headers:
Authorization: "Token {{ netbox_token }}"
content-type: "application/json"
return_content: yes
status_code: 200
register: nb_cf_lookup
vars:
nb_cf_json_local: >-
{{
(nb_cf_lookup.json is defined and nb_cf_lookup.json)
| ternary(nb_cf_lookup.json, (nb_cf_lookup.content | from_json))
}}
set_fact:
nb_baseline_ok: true
nb_device_id: "{{ nb_cf_json_local.results[0].id | default('') }}"
nb_custom_fields_current: "{{ nb_cf_json_local.results[0].custom_fields | default({}) }}"
changed_when: false
failed_when: false
- name: NB baseline | Set baseline facts
when:
- nb_cf_lookup is defined
- (nb_cf_lookup.status | default(0)) == 200
- (nb_cf_lookup.content | default('') | length) > 0
- name: NB baseline | Abort delta mode if baseline missing or unusable
delegate_to: localhost
vars:
nb_cf_json: "{{ nb_cf_lookup.json | default(nb_cf_lookup.content | from_json) }}"
set_fact:
nb_baseline_ok: true
nb_device_id: "{{ nb_cf_json.results[0].id | default('') }}"
nb_custom_fields_current: "{{ nb_cf_json.results[0].custom_fields | default({}) }}"
nb_baseline_ok: false
nb_custom_fields_current: {}
nb_device_id: ""
when: nb_device_id | length == 0
changed_when: false
- name: NB baseline | Debug baseline ok and a sample key
@@ -327,13 +326,6 @@
- "baseline fw_version={{ nb_custom_fields_current.get('fw_version','<missing>') }}"
changed_when: false
tasks:
- name: "⚙️ Start | Dev1 banner → tunnel/auth → Dev2 firmux (telemetry mode)"
debug:
msg:
- "Device: {{ inventory_hostname }}"
- "Mode: report-only (soft-fail telemetry)"
# ----------------------- Scan status tracking (journal finalization) -----------------------
- name: Init scan status tracking
delegate_to: localhost