1807
This commit is contained in:
@@ -288,6 +288,20 @@
|
|||||||
nb_custom_fields_current: {}
|
nb_custom_fields_current: {}
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
- name: NB baseline | Read id and custom_fields (fields)
|
||||||
|
delegate_to: localhost
|
||||||
|
uri:
|
||||||
|
url: "{{ netbox_url }}/api/dcim/devices/?name={{ inventory_hostname }}&fields=id,custom_fields"
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
Authorization: "Token {{ netbox_token }}"
|
||||||
|
return_content: true
|
||||||
|
status_code: 200
|
||||||
|
timeout: 10
|
||||||
|
register: nb_cf_lookup
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
# NOTE: this task must exist above (keep your existing one):
|
# NOTE: this task must exist above (keep your existing one):
|
||||||
# - name: NB baseline | Read id and custom_fields (fields)
|
# - name: NB baseline | Read id and custom_fields (fields)
|
||||||
# delegate_to: localhost
|
# delegate_to: localhost
|
||||||
@@ -303,8 +317,8 @@
|
|||||||
}}
|
}}
|
||||||
set_fact:
|
set_fact:
|
||||||
nb_baseline_ok: true
|
nb_baseline_ok: true
|
||||||
nb_device_id: "{{ nb_cf_json_local.results[0].id | default('') }}"
|
nb_device_id: "{{ (nb_cf_json_local.results | default([]) | first | default({})).id | default('') }}"
|
||||||
nb_custom_fields_current: "{{ nb_cf_json_local.results[0].custom_fields | default({}) }}"
|
nb_custom_fields_current: "{{ (nb_cf_json_local.results | default([]) | first | default({})).custom_fields | default({}) }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user