Automated Cisco UCS Server Provisioning part 2 (the meat!)
I have been working on this concept for a couple of months off and on in my spare time. The thought process was to create a script that performs the manual processes required to deploy an ESX (or Windows) server using Cisco UCS blades. This includes everything from generating the Service Profile to Storage Configuration to Installing the OS. Just like in my Part 1 post below are the script steps.
1. Generate Server from Cisco UCS Service Profile
2. Gather WWNN, WWPN, and MAC of eth0 (eth0 is my 3rd boot option under boot policy)
3. Generate zoning configuration/push to MDS 9509
4. Create boot LUN
5. Create storage group
6. Create initiator record for new server on the boot hba/fabric (in my case its Fabric B)
7. Add initiator/server to storage group
8. Add boot LUN to storage group
9. Generate pxelinux.cfg and kickstart files
10. Boot Service Profile/Initiate PXE install
I am happy to say I have successfully completed all steps in the above process. Below is a high level breakdown of what the script is doing. I believe I have broken down the script process within each section well enough for you to understand what is happening, if not let me know and I will be happy to describe it in more detail. At the end I have a video of the process in action. Please note I did this more to see if it was possible, so in order to make this script perform multiple installs at the same time you will need to make some modifications, but it does work for a single deploy. You can download the Server Build Script by clicking here. You can download the bundle of scripts by clicking here.
MODULE IMPORT SECTION:
This section imports all the required functions for the script to run properly. The four module scripts I have are:
· Automated-ESXi-Install.ps1 – Performs ESXi Install/Configuration
o generatePXEcfg – Creates PXE config file, places it on my PXE Server
o generateKS – Creates my KickStart file for the ESXi PXE Install
· Automated-ZoneCreations.ps1 – Performs all the Zone Functions
o SendKeysA – Sends configuration to MDS#1
o SendKeysB – Sends configuration to MDS#2
o createZoning –
§ Prompts for MDS Username/Password – Logs you in
§ Creates Text File for both MDS Configurations
§ Sends Zoning information to text file and putty session/repeats for all configurations
· Automated-StorageCreations.ps1 – Performs all the Storage Functions
o createSG – Creates the storage group
o registerHost – Creates initiator assigns it to the storage group
o createStorage –
§ Generates a list of all LUNs within the array that start with 22, adds 1 and 2 to that number to generate the new LUN numbers for this deploy. (e.g., say the last LUN in the line that starts with 22 is 2205, the new LUN numbers will be 2206 & 2207)
§ Creates LUN1 as R5 using the sizes/SP specified
§ Creates LUN2 as R5 using the sizes/SP specified
§ Creates/Expands new Metalun using LUN1 & LUN2 using the name specified
§ Adds the new Metalun to the Storage Group
· SendUCScmd.ps1 – Used to send XML Commands to UCS Nuova
GLOBAL VARIABLE SECTION:
This section is used to set some global variables used throughout the script.
· URL of the Fabric Interconnect Nuova
· Number of Service Profiles to build (this will break if you set it to 2 without adapting the rest of the script to handle multiple service profiles)
· The location to store the Zoning Config files (I use this just to have a copy of what was put into the MDS’s)
USER INPUT SECTION:
This section gathers all the necessary user input for the server to be deployed.
· UCS Username/Password
· What type of Server (this section needs to be modified to match your environment and when new service templates are created)
· The prefix for the Service Profile (UCS always appends a number to this)
· The server’s IP address (this is used for the initiator created on the array and for the ESXi KickStart file)
LOGIN/SERVER BUILD EXECUTION SECTION:
This section logs into the Nuova and performs the service profile creation
· Logs into the UCS Nuova
· Builds the service profile
VARIABLE SET/RETRIEVE SECTION:
This section sets the XML Commands for each server type, retrieves the new service profile variables, and converts the mac variable to a usable format.
· Sets the XML Commands based on Server Type
· Retrieves the WWNN, WWPN’s, and the MAC address for the new service profile
· Replaces the colon in the MAC to dashes (used for the PXE configuration file)
STORAGE EXECUTION SECTION:
This section performs all the storage creation for the new service profile; this includes array and zoning functions.
· Creates zoning and pushes configuration to both MDS’s
· Creates storage group
· Creates initiator and adds it to storage group
· Creates BootLUN and assigns it to the storage group (NOTE: rg1 and rg2 are the RAID Group Numbers you want to use for your LUN Provisioning, change to match your env.)
ASSIGN SERVER EXECUTION SECTION:
This section assigns the new service profile to a server within a server pool, and generates all necessary configuration files for the install process.
· ESX Servers –
o Generates PXE Configuration
o Generates KickStart Configuration
o Assigns the new service profile to the ESX Server Pool
· Windows Servers –
o Assigns the new service profile to the Windows Server Pool
This section terminates the UCS Nuova session.
This video shows me executing the script and it generating the service profile, pushing the zoning configuration into the MDS 9509’s, and the install of ESXi kick off/finish. I had to blur out quite a bit of stuff, but I think you get the idea.