HOWTO: Allocate IPs from NetBox Before Provisioning¶
Purpose: Claim IP addresses through NetBox IPAM before provisioning VMs, ensuring consistent addressing and a complete audit trail.
Difficulty: Intermediate
Track: IPAM-Driven Infrastructure
Overview¶
In HybridOps, IP addresses are never assigned ad hoc: they are allocated through NetBox before any provisioning step runs. This HOWTO covers the allocation pattern: finding the right prefix, creating the IP object, and feeding the result into the provisioning module input. It also covers the lifecycle end: releasing the IP when a VM is decommissioned.
1. Finding the Right Prefix¶
- Querying prefixes by VLAN and site in NetBox.
- Identifying available capacity.
- Prefix selection policy (avoid management and reserved ranges).
2. Allocating an IP¶
- Creating an IP address object via the NetBox API.
- Required fields: address, status, assigned object.
- Tagging with environment and role metadata.
3. Passing the IP to the Provisioning Module¶
- Exporting the allocation as a module input.
- Using the IPAM module output directly in the VM module input map.
- Handling allocation failures gracefully.
4. Post-Provisioning Validation¶
- Confirming the IP appears in NetBox as
active. - Verifying the interface binding is correct.
- Updating the DNS record if required.
5. Decommission and Release¶
- Marking the IP as
deprecatedon VM shutdown. - Releasing the allocation after decommission.
- Avoiding ghost allocations in long-running environments.
References¶
- ADR-0002 – Source of Truth: NetBox-Driven Inventory
- ADR-0104 – Static IP Allocation with Terraform IPAM
- HOWTO: Deploy NetBox Authoritative
- HOWTO: Run the Authoritative On-Prem Foundation
License: MIT-0 for code, CC-BY-4.0 for documentation unless otherwise stated.