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