NetBox Create VLAN Task¤
task API name:
create_vlan
The create_vlan task creates or updates one VLAN in an existing VLAN group. Supply vid for an explicit VLAN ID, or omit it to allocate the next available ID from the group's configured ranges.
Inputs¤
| Parameter | Required | Default | Description |
|---|---|---|---|
vlan_group |
Yes | — | Existing VLAN group name |
name |
Yes | — | VLAN name |
vid |
No | None |
Explicit VLAN ID from 1 through 4094; omit to allocate |
status |
No | active |
VLAN status |
description |
No | None |
VLAN description |
tenant |
No | None |
Tenant name |
role |
No | None |
IPAM role name |
tags |
No | None |
Tag names |
custom_fields |
No | None |
NetBox custom-field values |
instance |
No | Worker default | NetBox instance to target |
dry_run |
No | False |
Return the selected VID without writing |
branch |
No | None |
NetBox Branching plugin branch name |
Output¤
{
"vid": 1000,
"name": "USERS",
"vlan_group": "CAMPUS",
"status": "created",
}
status is create or update during dry-run and created or updated after an applied operation.
Examples¤
A dedicated NFCLI command is not currently registered for create_vlan.
# Use the Python API, REST API, MCP task interface, or design filter.
from norfab.core.nfapi import NorFab
with NorFab(inventory="./inventory.yaml") as nf:
client = nf.make_client()
allocated = client.run_job(
"netbox",
"create_vlan",
workers="any",
kwargs={"vlan_group": "CAMPUS", "name": "USERS"},
)
explicit = client.run_job(
"netbox",
"create_vlan",
workers="any",
kwargs={
"vlan_group": "CAMPUS",
"name": "SERVERS",
"vid": 1100,
},
)
In a NetBox design:
{% set users_vid = "CAMPUS" | netbox.create_vlan("USERS") %}
vlans:
- group: CAMPUS
vid: {{ users_vid }}
name: USERS
Notes / Gotchas¤
- The VLAN group must already exist and have available VID ranges for allocation.
- With an explicit
vid, identity is VLAN group plus VID. - Without
vid, an existing VLAN with the same group and name is reused. - Branch writes require the NetBox Branching plugin.
Troubleshooting¤
- VLAN group not found: verify the exact group name in NetBox.
- No available VLAN IDs: add or expand the group's VID ranges.
- Ambiguous identity: remove duplicate VLANs with the same group and identity fields.
Task Command Shell Reference¤
create_vlan does not currently have a dedicated NFCLI command model.
Python API Reference¤
Create, update, or allocate one VLAN in a VLAN group.
Source code in norfab\workers\netbox_worker\vlan_tasks.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |