vCenter Automated Install

So how long does it take you to install vCenter, not using the VCSA, but the Windows package? How many manual steps does it require you to perform? Have you actually ever counted? It is quite a lot.

I was presented with the following requirements for a project:

  • We need to install vCenter as part of a deliverable for a customer
  • The Installation should standard and repeatable.
  • The database will be on an external Oracle VM.
  • The process should be automated.
  • The whole process must be logged to a file.

So you might ask – why would you do this for a one time thing – I agree – you really wouldn’t. But in my case since this was to be used to deliver a solution to a substantial number of customers – then repeasting a manual installation each time was completely out of the question.

Going back to vCenter 5.0 it was actually pretty simple. Well not really simple but there are less moving parts, you run one script – pass the correct parameters, and hey presto you have a vCenter installed.

In vCenter 5.1, VMware made life a lot more complicated. When you install vCenter – you actually install 3 separate packages (and they have to be in the following order):

  1. Single Sign On
  2. Inventory Service
  3. vCenter Server

You can then also install the Web client – but this is not mandatory – but it is advised – this will be the last version of the Windows vSphere Client – you had better start getting used to the Web Client – so actually there are 4 packages.

VMware has separated this into two methods one of which is called the – Simple Install – which will install the whole thing for you in one shot – but your options of customization here are limited. Everything is installed with the defaults – all with embedded SQL databases – but not really what I would call production ready. That means you will need to install them separately.

Before I start I would like to point to two invaluable resources that helped me in preparing these scripts. This thread on VMTN (GrantOrchard provided the the syntax) and the Command-Line Installation and Upgrade of VMware vCenter Server 5.1 document – which has all the information you need.

There are a few points that I would like to make clear.

  • This post will not explain how to setup the Oracle Client on your vCenter server (that will require a separate post)
  • This post will not explain how to create the tablespaces and apply grants on the Oracle database. VMware do a good job of explaining that here (perhaps I will elaborate this post a bit further in the future on how that can be done in an automated way).

These are the pre-requisites to start with.

  1. You have an Oracle client on your Windows vCenter server – already pre-configured. In my case this was Oracle Thin Client.
  2. Powershell is installed
  3. Your tnsnames.ora is already configured.
  4. You have a remote Oracle Database VM.
  5. Both the vCenter tablespace and the Single Sign On tablespaces have already been created with their appropriate users and proper grants as documented here.
  6. You have an ODBC connection already setup and verified from the (to be) vCenter VM.
  7. The environment I am installing does not have DNS resolution between the VM’s therefore the hostname and IP of the database server need to be set in the hosts file.

And now to the script – annotations are at the end:

 ## =====================================================================
## Title       : vCenter51_Install
## Description : This script will install all the necessary components
##				 needed for vCenter 5.1
## Author      : Maish Saidel-Keesing
## Date        : 19/02/2013
## Usage	   : PS>  .\vcenter51_install.ps1
## Notes	   : More information about this scipt can be found at
##	    	     http://technodrone.blogspot.com
## Version     : 1.0.1
## =====================================================================

## Start Logging
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
$transcriptpath = ".\vCenter_install_" + (Get-Date -Format dd-MM-yyyy_HH-mm) + ".log"
Start-Transcript -path $transcriptpath -append | Out-Null

#Update Hosts file
$vcenterdb = Read-Host "Please Enter the IP address of the vCenterDB (Oracle) Server"
$hostsfile = "C:\Windows\System32\drivers\etc\hosts"
if (!$((Get-Content $hostsfile) | Select-String "vcenterdb")) {
	Write-host "Adding vcenterDB to the hosts file..." -ForegroundColor Green
	Add-Content "`r`n`n$vcenterdb`tvcenterdb" -Path $hostsfile
	if (((Get-Content $hostsfile) | Select-String "vcenterdb") -eq $null) {
		Write-Warning "Hosts file was not updated correctly!! Exiting.."

if (!$(Test-Path -Path 'c:\temp')) {
	New-Item -ItemType Directory -Path 'c:\temp' | Out-Null

#Define Parameters
$VCMedia = "C:\installs\VMware-VIMSetup-all-5.1.0-947939"
$LIKey = ""
$Username = "Maish"
$CompanyName = "maish"
$ODBCName = "vCenter"
$DBUser = "vpxadmin"
$DBPass = "vpxadmin"
$SSOpasswd = "Hello!2"
$SSO_ADMIN_USER = "admin@System-Domain"
$wipedb = "FORMAT_DB=1"
$vcenterIP = (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName .).IPAddress

#SSO installation
Write-Host "Installing Single Sign On" -ForegroundColor Green
$exe = "$VCmedia\Single Sign On\VMware-SSO-Server.exe"
$myargs = '/L1033 /v"/qr MASTER_PASSWORD=' + $SSOpasswd + ' RSA_DBA_PASSWORD=' + $RSA_DBA + ' RSA_USER_PASSWORD=' + $RSA_USER
$myargs = $myargs + ' CONFIG_TYPE=Setup SETUP_TYPE=Basic SSO_DB_SERVER_TYPE=Custom JDBC_DBTYPE=Oracle'
$myargs = $myargs + ' JDBC_USERNAME=' + $RSA_USER + ' JDBC_PASSWORD=' + $RSA_USER + ' COMPUTER_FQDN=\"' + $vcenterIP
$myargs = $myargs + '\" IS_SSPI_NETWORK_SERVICE_ACCOUNT=1 SSO_HTTPS_PORT=7444 /L*v \"C:\temp\ssoinstall.log\""'
Start-process $exe $myargs -Wait

#Inventory Service installation
Write-Host "Installing Inventory Service" -ForegroundColor Green
$exe = "$VCmedia\Inventory Service\VMware-inventory-service.exe"
$myargs = '/L1033 /v"/qr QUERY_SERVICE_NUKE_DATABASE=1 SSO_ADMIN_USER=\"' + $SSO_ADMIN_USER + '\" SSO_ADMIN_PASSWORD=\"' + $SSOpasswd + '\"'
$myargs = $myargs + ' LS_URL=\"https://' + $vcenterIP + ':7444/lookupservice/sdk\" HTTPS_PORT=10443 FEDERATION_PORT=10111 XDB_PORT=10109'
$myargs = $myargs + ' TOMCAT_MAX_MEMORY_OPTION=S /L*v \"C:\temp\inventoryservice_install.log\""'
Start-process $exe $myargs -Wait

# Install vCenter 
Write-Host "Installing vCenter Server" -ForegroundColor Green
$exe = "$VCmedia\vCenter-Server\VMware-vcserver.exe"
$myargs = '/L1033 /v" /qr DB_SERVER_TYPE=Custom DB_DSN=\"' + $ODBCName + '\"  DB_USERNAME=\"' + $DBUser +'\" DB_PASSWORD=\"' + $DBPass + '\" ' + $wipedb
$myargs = $myargs + ' JVM_MEMORY_OPTION=S SSO_ADMIN_USER=\"' + $SSO_ADMIN_USER + '\" SSO_ADMIN_PASSWORD=\"' + $SSOpasswd + '\"'
$myargs = $myargs + ' LS_URL=\"https://' + $vcenterIP + ':7444/lookupservice/sdk\" IS_URL=\"https://' + $vcenterIP + ':10443\"'
$myargs = $myargs + ' VC_JDBC_URL=\"jdbc:oracle:thin:@vcenterdb:1540:VCENTER\" VPX_USES_SYSTEM_ACCOUNT=1 COMPUTER_FQDN=\"' + $vcenterIP + '\"'
$myargs = $myargs + ' VC_ADMIN_USER=\"Administrators\" VC_ADMIN_IS_GROUP_VPXD_TXT=true VCS_GROUP_TYPE=Single VCS_ADAM_LDAP_PORT=389'
$myargs = $myargs + ' VCS_HEARTBEAT_PORT=902 /L*v \"C:\temp\vcenter_install.log\""'
Start-process $exe $myargs -Wait

#Install Web Client
Write-Host "Installing Web Client" -ForegroundColor Green
$exe = "$VCmedia\vSphere-WebClient\VMware-WebClient.exe"
$myargs = '/L1033 /v" /qr SSO_ADMIN_USER=\"' + $SSO_ADMIN_USER + '\" SSO_ADMIN_PASSWORD=\"' + $SSOpasswd + '\"'
$myargs = $myargs + ' LS_URL=\"https://' + $vcenterIP + ':7444/lookupservice/sdk\" HTTP_PORT=9090 HTTPS_PORT=9443'
$myargs = $myargs + ' /L*v \"C:\temp\weblient_install.log\""'
Start-process $exe $myargs -Wait

# Stop logging

Lines 13-18 – Creates a log file of the transcript to the current directory of the script.

Lines 20-30 – Remember there is no DNS resolution – the user is prompted for the IP address of the Oracle database (vCenterDB) and the entry is added to the local hosts file.

Lines 32-34 – All vCenter component installation logs will be written to C:\temp. If the directory does not exist – it will be created.

Line 36 – License Key – in my case was blank – and will be added at a later stage.

Line 37 – Location of the vCenter installation package.

Lines 39-40 – Windows details.

Lines 41-43 – ODBC details this includes the ODBC connection and credentials.

Line 44 – This is the password that you will use for the Single Sign On admin@System-Domain user.

Lines 45-46 – This is the usernames and passwords for the database for SSO. if you followed the default creation scripts provided by VMware – then the username and passwords witll be the same. If not – then you should add the additional variables for the passwords.

Line 47 – The SSO admin user.

Line 48 – If there was existing data in database – clean it out.

Line 49 – since there is no name resolution – everything will be done with IP, here we retrieve the IP of the vCenter server. through WMI.

Lines 52-59 SSO Installation - create the arguments that will be passed to the MSI file. This could all be on one line but I broke it down for easier reading. Here we use the variables defined above.

Line 60 – Execute the installation and wait for the command to exit before continuing.

Lines 62-68 – Same as above but for the Inventory service. Here no database is necessary – only the credentials for SSO.

Lines 70-80 – vCenter Server installation.

Line 76 – I want to point out here that the VC_JDBC_URL is specific to the Oracle thin client you can see all the options here JDBC URL Formats for the vCenter Server Database.

Lines 82-88 – Web Client installation.

Line 91 – Stop the transcript.

I would like to stress again that this was created for a specific use case with Oracle – but the information here will be able to assist you in adapting the script to your environment.

Start to finish – less than 15 minutes to install a full vCenter. How do you like them apples??