From 993fa3f591f34486ae8679ce85517871a038b09b Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Fri, 20 Jan 2023 13:24:50 +0100 Subject: [PATCH] updated netboxinventory state --- states/netboxinventory/init.sls | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/states/netboxinventory/init.sls b/states/netboxinventory/init.sls index 19070d5..8c98c62 100644 --- a/states/netboxinventory/init.sls +++ b/states/netboxinventory/init.sls @@ -7,17 +7,23 @@ netboxinventory-dependencies: {% set nodename = salt['grains.get']('nodename') %} {% set location = salt['grains.get']('location') %} {% set type = salt['grains.get']('type') %} +{% if salt['smbios.get']('system-manufacturer') %} {% set manufacturer = salt['smbios.get']('system-manufacturer') %} -{% set model = salt['smbios.get']('system-product-name') %} +{% else %}{% set manufacturer = "none" %}{% endif %} -{%- if salt['netbox.get'](app='dcim', endpoint='manufacturers', name=manufacturer) == {} %} +{% if salt['smbios.get']('system-manufacturer') %} +{% set model = salt['smbios.get']('system-product-name') %} +{% else %}{% set model = "none" %}{% endif %} + + +{%- if not salt['netbox.get'](app='dcim', endpoint='manufacturers', name=manufacturer) %} netbox.create_manufacturer_{{ manufacturer|md5 }}: module.run: - name: netbox.create_manufacturer - m_name: "{{ manufacturer }}" {%- endif %} -{%- if salt['netbox.get'](app='dcim', endpoint='device-types', model=model) == {} %} +{%- if not salt['netbox.get'](app='dcim', endpoint='device-types', model=model) %} netbox.create_device_type_{{ model|md5 }}: module.run: - name: netbox.create_device_type