Deploy and configure VMware NSX in 23 minutes
VMware NSX is completely software based. This means it’s flexible as heck and you can have a lot of instances running concurrently. It also means you can go crazy with your network topology designs and amount of tinkering you can do with your virtual network. I am someone who loves to tinker. Sometimes a bit too much. A consequence of this, is that I sometimes break my virtual test lab and have to re-install it and return to the starting point. This has happened a few times.
I also like to use clean labs for customer demo purposes, just to make sure everything is clean and working for the demo. I have done the base install of NSX too many times and repetitive tasks need to be automated. :-) With these reasons combined, I created a solution to deploy and configure VMware NSX in 23 minutes.
By the way, if you’re curious about the 23 minutes in the title, check the timer in the usage paragraph below.
PowerNSX is a pretty complete PowerShell module for VMware NSX. The current development version includes a lot more functions than version 1, including a function to deploy the NSX Manager and register it to vCenter. This gave me an idea to create a script using PowerNSX to do the complete base install of NSX and save me a hour or two each time I need a clean environment. And in the words of a famous poet, ‘Well, that idea escalated quickly’.
The script has evolved quite a bit and I’ve used it pretty often by now. It currently can do the following for you:
- Deploy NSX Manager Appliance;
- Do the registration to vCenter so the NSX plugin becomes available;
- Deploy a dynamic amount of NSX Controllers;
- Prepare ESXi hosts for NSX (install the VIBs);
- Configure VXLAN on the ESXi hosts and do multicast & distributed switch configuration;
- Add VMs to the Distributed Firewall exclusion list;
- Create Logical Switches;
- Create Edge Services Gateways;
- Create Distributed Logical Routers.
All of this is packed in an Excel file for configuration, a slightly modified PowerNSX module and a script with which you can choose what you want to do. Want to only use it to create a bunch of Logical Switches? Or a quick base install? It can help you with that.
Using the installation script is pretty basic, just be sure the Excel file is filled out properly. The current state of the installation script is not forgiving when it comes to the information it needs. If something is missing out or incorrect, it’ll just fail halfway the task. Can’t say I didn’t warn you. :-)
Once you’ve filled out the enter Excel file and downloaded the NSX Manager OVA, you can decide exactly what you want to do. Just a quick base install, or the whole shebang?
Usage: .\Install-NSX.ps1 -SettingsExcel C:\install-nsx-info.xlsx - Mother of all information (required) -NSXManagerOVF C:\VMware-NSX-Manager-6.2.2-3604087.ova - Location of the NSX Manager OVA (optional) (yes, you have to download this yourself) -DeployOVF - Deploy the NSX Manager (optional) -RegistervCenter - Register the NSX Manager to vCenter and SSO (optional) -DeployControllers - Deploy the configured amount of NSX controllers (optional) -PrepareCluster - Prepare the ESXi hosts in the vSphere cluster, configure VXLAN and add a Transport Zone (optional) -AddExclusions - Add the VMs to the distributed firewall exclusion list (optional) -CreateLogicalSwitches - Create Logical Switches (optional) -CreateEdges - Create Edge Services Gateways (optional) -CreateDLRs - Create Distributed Logical Routers (optional)
Only the -SettingsExcel parameter is required and you can supply all other parameters as you see fit. To execute all tasks, supply all paramaters. To only create Logical Switches, only use the -SettingsExcel and -CreateLogicalSwitches parameters.
Here’s an example to deploy and configure the whole shebang:
PowerCLI D:\git\install-nsx> .\Install-NSX.ps1 -SettingsExcel D:\git\install-nsx-info.xlsx -NSXManagerOVF D:\git\VMware-NSX-Manager-6.2.2-3604087.ova \ -DeployOVF -RegistervCenter -DeployControllers \ -PrepareCluster -AddExclusions -CreateLogicalSwitches \ -CreateEdges -CreateDLRs Starting NSX Manager deployment... Deployed NSX Manager! If you have other tasks for me, wait for the NSX Management Service to come onli ne and press any key to continue... Connecting to NSX Manager and registering it to vCenter... WARNING: NSX Manager does not currently have a vCenter registration. Use Set-NsxManager to register a vCenter server. Configured vCenter and SSO on NSX Manager! Deploying NSX Controllers (1)...(this will take a while) Deloying controller 1 ... Controllers deployed! Preparing vSphere cluster VSAN (installing VIBs)... Configuring VXLAN on cluster VSAN Adding a segment ID range.. Adding a multicast IP range.. Adding the VXLAN IP Pool.. Configuring VXLAN VTEPs on the cluster.. Adding transport zone.. Cluster prepared! Adding VM exclusions from the distributed firewall.. Added 2 VMs to exclusion list! Creating Logical Switches.. Added 3 Logical Switches! Creating Edge Services Gateways.. Added 2 Edge Services Gateways! Creating Distributed Logical Routers.. Added 1 Distributed Logical Routers! 00:23:07.7782050
The installation script is available on GitHub. It’ll be improved as I use it more and need more functionality.
If you end up using it, let me know! Would love to know your use-cases.
big thanks Martijn, you are the man right fucking there!!!
WOW! that´s what I need to finally start my NSX LAB! Thanks a lot!
Hi Martijn, I’m the author of PowerNSX, awesome to see you using my module in this way.
v2 is just around the corner, but you beat me to the punch as I’ve been sitting on almost exactly this functionality for a few months that I was going to release with it! :)
I’m intrigued by the modifications you had to make to PowerNSX for your script to function – can you drop me a line @ nbradford _at_ vmware _dot_ com and let me know of any additional functionality you’d like to see in PowerNSX?
Dude, I give you mad props!! This script is phuckin’ “face meltingly” AWESOMENESS!! Between William Lam’s AUTOLAB DEPLOYMENT, Nick Bradford’s PowerNSX, and your NSX in 23 minutes script, you can have a fully functional vCenter / vSphere 6.5 lab w/NSX completely functional from scratch in less than an hour!! Phuckin awesome. You guys are the bomb!! Keep up the good work!! One question. Is there options within Excel I might be missing or that are undocumented to add add’l uplinks and interfaces on DLRs and EDGEs or do you just get the one vnic0 uplink?
Hi Stacey, Thanks for the kind words! Glad it’s useful for you.
For your question; you didn’t miss a field in the Excel – I didn’t put support for multiple interfaces in there. Wasn’t a top priority for my own environment. It is possible to do so with PowerNSX though, here’s an example:
$vnic0 = New-NsxEdgeInterfaceSpec -Index 0 -Name $Edge_VNIC0_Name -Type Uplink -ConnectedTo $connectedTo -PrimaryAddress $Edge_VNIC0_IP -SubnetPrefixLength $Edge_VNIC0_Prefixlength
$vnic1 = New-NsxEdgeInterfaceSpec -Index 1 -Name $Edge_VNIC1_Name -Type Internal -ConnectedTo $vnic1_connectedTo -PrimaryAddress $Edge_VNIC1_IP -SubnetPrefixLength $Edge_VNIC1_Prefixlength
$edge = New-NsxEdge -Name $Edge_Name -Cluster (Get-Cluster -Name $Edge_Cluster) -Datastore (Get-Datastore -Name $Edge_Datastore) -FormFactor $Edge_FormFactor -Password $Edge_Password -Hostname $Edge_Hostname -EnableHa:$enableHA -Interface $vnic0,$vnic1
You’ll recognise the first and third line from my script on Github. The second line defining $vnic1 is new and on the last line, there’s on subtle change: “-Interface $vnic0” is now “-Interface $vnic0,$vnic1” – You can go on to the limit of 10 there. Hope that helps.