VMWare released Update 1 for vSphere 5.0 this month. With that update and the success I've had with vSphere v5.0 on our test servers, I've decided to start the production rollout.
We have over 30 ESX Hosts. After two the rollout really started to get bogged down with lots of little configuration changes for each new host. I'm doing a fresh install of ESXi blowing away the old ESX install. I feel that this is a cleaner build. The problem with that route is now all the configuration for NTP servers, syslog, firewall ports, and the worse part...network configuration has to be done by hand.
The network configuration is the worse part. Lots of little peices need changes. About 30% of the upgrade time was spent just on the network configuration page. This would be a good time to upgrade to Enterprise Plus and get the host profiles features. Unfortunately that upgrade is way too much money.
Instead I wrote a script to do most of the configuration. I was surprised at how easy it was to write that I don't have much Power CLI expertise. It works very well. It took about 30 minutes to write and test. Running the script reduces my work from about 20 boring minutes per host to about 20 seconds. Definitely worth the time spent to write the script.
The script handles networking, syslog, ntp, and datastore configuration
Here it is...
$esx_host = "esx10.vcnyc.indemand.net"
$vmmotion_ip = "10.12.6.19"
$nfs_ip = "10.12.19.110"
$vswitch = Get-VirtualSwitch -VMHost $esx_host -Name vSwitch0
New-VirtualPortGroup -Name VMMotion -VirtualSwitch $vswitch -VLanId 6
New-VMHostNetworkAdapter -VMHost $esx_host -PortGroup VMMotion -VirtualSwitch $vswitch -IP $vmmotion_ip -SubnetMask 255.255.255.0 -VMotionEnabled $true
# Other policies http://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/LoadBalancingPolicy.html
New-VirtualSwitch -VMHost $esx_host -Name vSwitch1 -Nic vmnic2, vmnic3
New-VirtualSwitch -VMHost $esx_host -Name vSwitch2 -Nic vmnic4, vmnic5
$policy = Get-VirtualSwitch -VMHost (Get-VMHost $esx_host) -Name vSwitch1 | Get-NicTeamingPolicy
$policy | Set-NicTeamingPolicy -LoadBalancingPolicy LoadBalanceIP
$vswitch = Get-VirtualSwitch -VMHost $esx_host -Name vSwitch1
New-VirtualPortGroup -Name NFS_Storage -VirtualSwitch $vswitch -VLanId 19
New-VMHostNetworkAdapter -VMHost $esx_host -PortGroup NFS_Storage -VirtualSwitch $vswitch -IP $nfs_ip -SubnetMask 255.255.255.0
$policy = Get-VirtualSwitch -VMHost (Get-VMHost $esx_host) -Name vSwitch2 | Get-NicTeamingPolicy
$policy | Set-NicTeamingPolicy -LoadBalancingPolicy LoadBalanceIP
$vswitch = Get-VirtualSwitch -VMHost $esx_host -Name vSwitch2
New-VirtualPortGroup -Name VLAN001 -VirtualSwitch $vswitch
New-VirtualPortGroup -Name VLAN003 -VirtualSwitch $vswitch -VLanId 3
New-VirtualPortGroup -Name VLAN015 -VirtualSwitch $vswitch -VLanId 15
New-VirtualPortGroup -Name VLAN007 -VirtualSwitch $vswitch -VLanId 7
New-VirtualPortGroup -Name VLAN014 -VirtualSwitch $vswitch -VLanId 14
New-VirtualPortGroup -Name VLAN010 -VirtualSwitch $vswitch -VLanId 10
Add-VmHostNtpServer -NtpServer us.pool.ntp.org -VMHost $esx_host
$ntp = Get-VmHostService -VMhost $esx_host | Where {$_.Key -eq 'ntpd'}
Set-VMHostService -HostService $ntp -policy "automatic"
$ftpFirewallExceptions = Get-VMHostFirewallException -VMHost $esx_host | where {$_.Name.StartsWith('NTP Client')}
$ftpFirewallExceptions | Set-VMHostFirewallException -Enabled $true
Set-VMHostSysLogServer -SysLogServer udp://vc1.vcnyc.indemand.net:514 -VMHost $esx_host
$ftpFirewallExceptions = Get-VMHostFirewallException -VMHost $esx_host | where {$_.Name.StartsWith('syslog')}
$ftpFirewallExceptions | Set-VMHostFirewallException -Enabled $true
New-Datastore -VMHost $esx_host -Nfs -Name VM_VSWP01 -NfsHost 10.12.19.23 -Path /vol/VM_VSWP01
New-Datastore -VMHost $esx_host -Nfs -Name VM_OS01 -NfsHost 10.12.19.23 -Path /vol/VM_OS01
New-Datastore -VMHost $esx_host -Nfs -Name VM_DATA01 -NfsHost 10.12.19.23 -Path /vol/VM_DATA01
New-Datastore -VMHost $esx_host -Nfs -Name VM_DATA10K01 -NfsHost 10.12.19.23 -Path /vol/VM_DATA10K01
New-Datastore -VMHost $esx_host -Nfs -Name VM_VSWP02 -NfsHost 10.12.19.24 -Path /vol/VM_VSWP02
New-Datastore -VMHost $esx_host -Nfs -Name VM_OS02 -NfsHost 10.12.19.24 -Path /vol/VM_OS02
New-Datastore -VMHost $esx_host -Nfs -Name VM_DATA02 -NfsHost 10.12.19.24 -Path /vol/VM_DATA02
Comments