Script to update netbox with vsphere VMs
NOTE: Under active development atm, not suitable for general use yet!
I didn't like the options / existing scripts I found, so decided to create my own instead
We dont push IP addresses that doesn't already exist in Netbox, as Netbox should be the source of truth for the desired network state.
It doesn't assume much about the vcenter/netbox setup, other than you need to add a custom field to netbox, so we have a unique id we can use when updating the netbox objects, in case a vms get renamed etc. We also have a second custom field, that controls whether we should update a VMs interfaces automatically, it defaults to false, but new VMs created by the script will be set to true.
You can create the necessary custom fields in Netbox:
- Netbox Administration -> Extras -> Custom fields -> Add
- Select
virtualization->cluster
andvirtualization->virtual machine
in Object(s) - Set type to
text
- Set name to
vcenter_persistent_id
- Filter logic: Disabled
- Netbox Administration -> Extras -> Custom fields -> Add
- Select
virtualization->virtual machine
in Object(s) - Set type to
boolean
- Set name to
interface_sync_enabled
- Set default to false