Skip to content

Jinja2 Variable Support for Zabbix Inventory Fields #35

@taofineberg

Description

@taofineberg

Is it possible to use Jinja2 variables in the Inventory configuration?

Use Case
It would be extremely useful to sync inventory data (e.g., Latitude/Longitude, address, location details, etc.) from NetBox to Zabbix automatically, rather than manually populating each field with data that already exists in NetBox.

Proposed Solution
Ideally, this functionality could be added to the new Configuration Group feature—which is a great addition, by the way!

Related Work / Findings
I was able to get Jinja2 variables working for Tags and Host Groups by modifying the following files to extend the context:

zabbixtagassignment.py - Adds site, tenant, role, device_type, manufacturer to ZabbixTagAssignment.get_context()
zabbixhostgroupassignment.py - Adds site, tenant, role, device_type, manufacturer to ZabbixHostgroupAssignment.get_context()

Then use
{{ manufacturer.name }}
{{ site.name }}
{{ device_type.model }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions