Skip to content

feat: ZabbixTemplateRule regex template assignment (with hostgroup/tag and API) - #117

Closed
berlikm wants to merge 2 commits into
OpensourceICTSolutions:developmentfrom
berlikm:feature/templaterule-regex
Closed

berlikm wants to merge 2 commits into
OpensourceICTSolutions:developmentfrom
berlikm:feature/templaterule-regex

Conversation

@berlikm

@berlikm berlikm commented Jul 13, 2026 •

Copy link
Copy Markdown

Summary

ZabbixTemplateRule — regex template (+ optional hostgroup/tag) assignment by platform name (#121).

Rebased onto 1.0.5 + #115. Depends on #115. TemplateRule-only delta:

https://github.com/berlikm/nbxsync/compare/feature/site-region-inheritance...feature/templaterule-regex

Highlights

  • Full NetBox surface (forms/filtersets/tables/views/API)
  • Migration 0015
  • Safe matching: re.search, nested-quantifier reject, 64-char cap (no SIGALRM)

Scope frozen at tip 90714ed.

Merge after: #115
Next: #110

@berlikm

berlikm commented Jul 14, 2026

Copy link
Copy Markdown
Author

This PR is part of the zero-touch provisioning feature set described in #121. Please see that issue for the full architecture and motivation.

@berlikm

berlikm commented Jul 16, 2026

Copy link
Copy Markdown
Author

Missing template file

This PR is missing the nbxsync/templates/nbxsync/zabbixtemplaterule.html template. When a user clicks on a ZabbixTemplateRule in the UI to view its detail page, NetBox throws:

django.template.exceptions.TemplateDoesNotExist: nbxsync/zabbixtemplaterule.html

The ZabbixTemplateRuleView (ObjectView) at views/zabbixtemplaterule.py:27 expects this template to exist. I've pushed commit 8ef5cdb to this branch with the missing template file — a standard NetBox object detail template showing the rule's pattern, template, hostgroup, tag, priority, and enabled status.

@light-foot

Copy link
Copy Markdown

Just a thought, would it make sense to expand this a bit?
For device roles, if a device has a certain role could we regex match against platform? In our network we have devices that have certain roles and sometimes the device isn't always the same vendor, which changes the template requirements.

@cursor
cursor Bot force-pushed the feature/templaterule-regex branch from 8ef5cdb to 2f79570 Compare July 30, 2026 23:08
@berlikm berlikm changed the title Feature: Add ZabbixTemplateRule for regex-based template assignment by platform name feat: ZabbixTemplateRule regex template assignment (with hostgroup/tag and API) Jul 30, 2026
@cursor
cursor Bot force-pushed the feature/templaterule-regex branch 3 times, most recently from a544e34 to 889a5a3 Compare July 31, 2026 09:24
@berlikm

berlikm commented Aug 3, 2026

Copy link
Copy Markdown
Author

@light-foot good point — extending rule criteria kept coming up. We ended up not widening the TemplateRule: role-based assignment already exists natively (assign template/hostgroup directly to a DeviceRole), and tag-based assignment is now solved by making NetBox Tags first-class assignment targets in #115 (Assign hostgroup X to tag critical, automatic lifecycle). If you still need a combined predicate (role AND platform regex together), happy to revisit rule criteria as a follow-up — say the word.

@berlikm

berlikm commented Aug 3, 2026

Copy link
Copy Markdown
Author

@light-foot follow-up: it's in. Rules now support conjunctive criteria — pattern (platform regex), role_pattern (role name regex) and require_tags (comma-separated NetBox tag slugs, all required). Any combination ANDs; empty = wildcard. Example for your vendor-mixed roles: pattern=ESXi, role_pattern=Hypervisor pins a template exactly to that slice. Criteria evaluated safely (same ReDoS guards as pattern), and a set criterion on an object missing that value fails closed. Tests cover the full matrix; verified live on Zabbix 7.0.

cursoragent and others added 2 commits August 14, 2026 11:43
…n and inherited sync UI

Rebased onto 1.0.5 development (36fb2c4).

Keeps Site/SiteGroup/Region/Tag assignment targets, recursive ancestry,
exclude_tag, inherited sync status UI, and migrations 0013/0014.
Takes 1.0.5 trigger-dependency settings (enabled=False by default),
template pattern extraction, gettext_lazy, and CI pin to NetBox v4.6.7.

Not in this PR: TemplateRule (#117), device-context render (#110),
host bindings (#125), use_oob_ip (#129).

Co-authored-by: berlikm <[email protected]>
…g and API)

Rebased onto 1.0.5 + #115. Unique TemplateRule surface, migration 0015,
and inheritance matching. Query counts use the 1.0.5 NetBox v4.6.7
baselines plus TemplateRule views.

Co-authored-by: berlikm <[email protected]>
@berlikm

berlikm commented Aug 14, 2026

Copy link
Copy Markdown
Author

Restacked onto the 1.0.5 rebase of #115.

This is still TemplateRule-only (migration 0015, forms/API/views, regex matching in inheritance). Query counts use the 1.0.5 NetBox v4.6.7 baselines plus the TemplateRule views.

Trigger-dependency sync is unchanged from 1.0.5: disabled by default, one hook after the host assignment loop. Not part of this PR.

Scope frozen at 90714ed. Merge after #115; next is #110.

@berlikm berlikm closed this Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants