This commit is contained in:
2025-10-28 09:35:07 +02:00
parent 7e7da74f55
commit f5b82755fd

View File

@@ -218,18 +218,40 @@
debug:
msg: "Dev1 fw_version {{ dev1_fw_clean | default('N/A') }}"
# ---- NEW: read NetBox current custom field for Dev1 and conditionally publish ----
# ---- Coalesced read of NetBox custom field for Dev1 (handles different inventory shapes)
- name: NetBox | Current custom fw_version
set_fact:
nb_fw_version: "{{ (hostvars[inventory_hostname].custom_fields.fw_version | default('')) }}"
nb_fw_version: >-
{{
(
hostvars[inventory_hostname].custom_fields.fw_version
| default('', true)
)
or
(
hostvars[inventory_hostname].nb_custom_fields.fw_version
| default('', true)
)
or
(
hostvars[inventory_hostname].custom_fields_fw_version
| default('', true)
)
or
(
hostvars[inventory_hostname].fw_version
| default('', true)
)
| string | trim
}}
- name: Dev1 | Version matches NetBox → skip update
when: (dev1_fw_clean | default('')) == (nb_fw_version | default(''))
when: (dev1_fw_clean | default('') | trim) == (nb_fw_version | default('') | trim)
debug:
msg: "version matches, we'll skip Netbox update"
- name: Publish Dev1 fw_version
when: (dev1_fw_clean | default('')) != (nb_fw_version | default(''))
when: (dev1_fw_clean | default('') | trim) != (nb_fw_version | default('') | trim)
delegate_to: localhost
uri:
url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost | urlencode }}/{{ rmq_exchange | urlencode }}/publish"
@@ -324,18 +346,40 @@
| trim
}}
# ---- NEW: read NetBox current custom field for Dev2 and conditionally publish ----
# ---- Coalesced read of NetBox custom field for Dev2 (handles different inventory shapes)
- name: NetBox | Current custom indoor_fwver
set_fact:
nb_indoor_fwver: "{{ (hostvars[inventory_hostname].custom_fields.indoor_fwver | default('')) }}"
nb_indoor_fwver: >-
{{
(
hostvars[inventory_hostname].custom_fields.indoor_fwver
| default('', true)
)
or
(
hostvars[inventory_hostname].nb_custom_fields.indoor_fwver
| default('', true)
)
or
(
hostvars[inventory_hostname].custom_fields_indoor_fwver
| default('', true)
)
or
(
hostvars[inventory_hostname].indoor_fwver
| default('', true)
)
| string | trim
}}
- name: Dev2 | Version matches NetBox → skip update
when: (indoor_fw_norm | default('')) == (nb_indoor_fwver | default(''))
when: (indoor_fw_norm | default('') | trim) == (nb_indoor_fwver | default('') | trim)
debug:
msg: "version matches, we'll skip Netbox update"
- name: Publish Dev2 indoor_fwver
when: (indoor_fw_norm | default('')) != (nb_indoor_fwver | default(''))
when: (indoor_fw_norm | default('') | trim) != (nb_indoor_fwver | default('') | trim)
delegate_to: localhost
uri:
url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost | urlencode }}/{{ rmq_exchange | urlencode }}/publish"