diff --git a/netbox/netbox.py b/netbox/netbox.py index 04ca2fa..6cc34ed 100755 --- a/netbox/netbox.py +++ b/netbox/netbox.py @@ -308,7 +308,13 @@ def get_host_vars(self, host_data, host_vars): for var_name, var_data in host_vars[category].items(): # This is because "custom_fields" has more than 1 type. # Values inside "custom_fields" could be a key:value or a dict. - if isinstance(data_dict.get(var_data), dict): + if var_data == "config_context": + var_value = data_dict.get(var_data) + if var_value and var_value.get('configuration'): + var_value = var_value['configuration'] + else: + var_value = None + elif isinstance(data_dict.get(var_data), dict): var_value = self._get_value_by_path(data_dict, [var_data, key_name], ignore_key_error=True) else: var_value = data_dict.get(var_data) diff --git a/netbox/netbox.yml b/netbox/netbox.yml index ec86312..6e0daa8 100644 --- a/netbox/netbox.yml +++ b/netbox/netbox.yml @@ -23,6 +23,7 @@ netbox: # Any other sections. general: rack_name: rack + config: config_context # Custom sections (custom_fields) could be used as vars too. #custom: # env: env