Pcornel
Automation · IPAM Automation

IP Allocation

Cheat sheet · https://pcornel.dk/topic.php?topic=5867

Back to the Topic

Answer

IP allocation automation picks the next free address or prefix from the right pool, marks it as used atomically to avoid two jobs taking the same one, and releases it when the system is removed.

Remember

  • Allocation must be atomic to avoid duplicates.
  • Allocate from the correct pool or prefix.
  • Release addresses on decommission.

First checks

  • curl -s -X POST -H 'Authorization: Token <t>' -H 'Content-Type: application/json' -d '{"description":"vm01"}' https://<netbox>/api/ipam/prefixes/<id>/available-ips/ — allocate next IP
  • Idempotency (check existing by name/tag first) — no duplicates
  • Release on decommission — cleanup

Verify in this order

request → available-ips → allocated IP

Where it usually breaks

Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5867

Confirmation

Confirm action

Continue?