1814
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
control_queue: "{{ lookup('env','CONTROLQUEUE') | default('queue_controls', true) }}"
|
||||
|
||||
# NetBox API (delta compare; user may override)
|
||||
netbox_url: "http://netbox.gt-tiso.ikeja.co.za/api/"
|
||||
netbox_url: "http://netbox.gt-tiso.ikeja.co.za"
|
||||
netbox_token: "7648e4f5ee370cda7834682e61b47c2ee8e95623"
|
||||
|
||||
# --- Retry attempt tracking (default 0 if missing) ---
|
||||
@@ -288,6 +288,14 @@
|
||||
nb_custom_fields_current: {}
|
||||
changed_when: false
|
||||
|
||||
- name: NB baseline | Debug netbox_url used
|
||||
delegate_to: localhost
|
||||
debug:
|
||||
msg:
|
||||
- "netbox_url={{ netbox_url }}"
|
||||
- "inventory_hostname={{ inventory_hostname }}"
|
||||
changed_when: false
|
||||
|
||||
- name: NB baseline | Read id and custom_fields (fields)
|
||||
delegate_to: localhost
|
||||
uri:
|
||||
@@ -295,6 +303,7 @@
|
||||
method: GET
|
||||
headers:
|
||||
Authorization: "Token {{ netbox_token }}"
|
||||
Accept: "application/json"
|
||||
return_content: true
|
||||
status_code: 200
|
||||
timeout: 10
|
||||
@@ -302,25 +311,43 @@
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
# 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)
|
||||
- name: NB baseline | Debug raw response if json not parsed
|
||||
delegate_to: localhost
|
||||
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 | default([]) | first | default({})).id | default('') }}"
|
||||
nb_custom_fields_current: "{{ (nb_cf_json_local.results | default([]) | first | default({})).custom_fields | default({}) }}"
|
||||
debug:
|
||||
msg:
|
||||
- "nb_cf_lookup.status={{ nb_cf_lookup.status | default('NA') }}"
|
||||
- "nb_cf_lookup.content_type={{ nb_cf_lookup.content_type | default('NA') }}"
|
||||
- "nb_cf_lookup.json_defined={{ (nb_cf_lookup.json is defined) }}"
|
||||
- "nb_cf_lookup.content_head={{ (nb_cf_lookup.content | default('') | regex_replace('\\n',' ') )[:200] }}"
|
||||
when: nb_cf_lookup.json is not defined
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: NB baseline | Set baseline facts (best effort; never crash play)
|
||||
delegate_to: localhost
|
||||
block:
|
||||
- name: NB baseline | Choose parsed payload (json or content)
|
||||
set_fact:
|
||||
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))
|
||||
}}
|
||||
changed_when: false
|
||||
|
||||
- name: NB baseline | Set baseline facts from payload
|
||||
set_fact:
|
||||
nb_baseline_ok: true
|
||||
nb_device_id: "{{ (nb_cf_json_local.results | default([]) | first | default({})).id | default('') }}"
|
||||
nb_custom_fields_current: "{{ (nb_cf_json_local.results | default([]) | first | default({})).custom_fields | default({}) }}"
|
||||
changed_when: false
|
||||
|
||||
rescue:
|
||||
- name: NB baseline | Baseline parse failed (disable delta mode)
|
||||
set_fact:
|
||||
nb_baseline_ok: false
|
||||
nb_device_id: ""
|
||||
nb_custom_fields_current: {}
|
||||
changed_when: false
|
||||
|
||||
- name: NB baseline | Abort delta mode if baseline missing or unusable
|
||||
delegate_to: localhost
|
||||
@@ -339,7 +366,6 @@
|
||||
- "nb_device_id={{ nb_device_id }}"
|
||||
- "baseline fw_version={{ nb_custom_fields_current.get('fw_version','<missing>') }}"
|
||||
changed_when: false
|
||||
|
||||
# ----------------------- Scan status tracking (journal finalization) -----------------------
|
||||
- name: Init scan status tracking
|
||||
delegate_to: localhost
|
||||
|
||||
Reference in New Issue
Block a user