Two scripts created to import Linux servers into NetBox. Tested on Ubuntu and CentOS. All hosts should have LLDP enabled so connections can be mapped in NetBox.
The main provision script is intended to be run on a child device (server) that will be racked into a parent chassis. In our case since most of our servers are blade types we choose to rack 1 node systems into a parent chassis for overall consistency. This script was tested on 1 Node parent/child as well.
- Seed NetBox with server data gathered with NorNir and Napalm via LLDP and ARP info. The minios script creates a base system in NetBox.
You can bypass the script and just create a base system (CSV Import) in NetBox as shown below and run the main provision script on that.
Provision script must have a "Base" system in place. If you used the seed script you will also have IP's you need to add to /etc/host file so no DNS is needed for SSH to work.
This is the parent chassis that the script is going to install the child server into, it will also add power connections and info based off server
The main provision script will take the shell from above and fill in many key details for you automatically.
-
Gather all facts about a server and add them to NetBox. This includes manafucturer, product type, serial number, asset tags, ethernet interface and IP BMC interface and IP and it will also make the interface connections in NetBox based of LLDP information it finds so that you will be able to see the active LLDP connections in NetBox GUI.
-
Still a work in progress as time allows but there are lots of things I'd like to fix in this script. It's a learning process and grew very organically.
Final State with Device Type, Serial, Role, Rack, Status, and Custom Fields for BIOS and BMC info
LLDP used to make the connections in netbox, ARP and IPMITOOL used to find ETH and BMC IP addresses
Child Server is racked into the parent based off the chassis serial number. Set the node as a script option. Script still works if wrong node selcted, it will just leave the system unracked. Run the script again with the correct node and it will slot it correctly.
Power connections created on the chassis and max power and allocation also set.