VSphere Host Profiles vs. PowerCLI: The war for automation supremacy

VSphere Host Profiles vs. PowerCLI: The war for automation supremacy

One of my occupational hazards is constantly being asked which technologies to use for virtualized environments. Customers often ask whether to use vSphere Host Profiles or PowerCLI scripts to configure ESX or ESXi hosts.

For me, automating the build process is the first step toward ensuring consistency and reliability. It also aids the rollout of a new product version or rebuilding a failed host.
Of course, some folks say they don't use vSphere Host Profiles or PowerCLI scripts.

They have only four ESX hosts to configure, for example. And then they mistype a domain name server entry or forget to set the network time protocol consistently.

    Requires Free Membership to View

    When you register, my team of editors will also send you alerts covering all areas of VMware, such as implementing VMware-related virtualization technologies for server consolidation, disaster recovery and backup strategies, management and performance, VM migration and more.

    Margie Semilof, Editorial Director

    By submitting your registration information to SearchVMware.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchVMware.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

With an automated build process, you'll save time by blowing up a configuration and starting over, rather than upgrading or repairing a host -- which can be time consuming. You can trust that your script will bring the hosts to their original state when ESX/ESXi was first installed and configured.

Host Profiles, on the other hand, appeal to folks with a pathological aversion to scripting environments. Through vCenter Server, administrators can create host templates with preconfigured settings, called a host profile, and quickly apply them to new hosts. So which method should you use: PowerCLI or Host Profiles?

VSphere Host Profiles: Pros and cons
VSphere Host Profiles' biggest advantage is the ability to copy the configuration of existing vSphere host and apply it to another host. It's even better when your server vendor has a hardware profile system for configuring a blade server that seamlessly integrates with a host profile. This combination greatly reduces the configuration time and speeds deployment.

Sadly, vSphere Host Profiles is far from perfect. As a configuration tool, it currently and inexplicably doesn't offer options for setting up VMware iSCSI Initiator. (The operative word in the last sentence is currently.)

Also, a host profile can be applied only when vSphere hosts are in maintenance mode, which entails the migration of all VMs to another host with vMotion. This limitation is fine if you're working on a brand-new server that hasn't been configured to support virtual machines. But it can be a problem if you have 32 hosts to reconfigure. My point is that vSphere Host Profiles is a great configuration tool, but it's not really viable as a reconfiguration tool.

Ultimately, this debate may be meaningless to you, however. Host Profiles is available only to Enterprise Plus customers. In contrast, VMware PowerCLI -- one for most useful toolkits -- is free. It's just a shame that VMware hobbled PowerCLI's functionality in free edition of VMware ESXi. You can retrieve information with PowerCLI but you can't change configurations.

Advantages of PowerCLI
Suppose your boss says that a new iSCSI target settings needs to be created on your 32-node ESX host cluster. Your options are limited because Host Profiles doesn't currently configure the ISCSI stack in ESX. (Again, notice the word currently.)

You could ditch iSCSI and move to a different storage protocol, such as Fibre Channel or Network File System. If you went down this route, expect your boss to call those nice men with the white coats to take you to the happy place for a couple of months.

The following approach would be more astute:

  1. Open PowerCLI.
  2. Log in to the vCenter Server that manages the cluster.
  3. Run the script below:

$targets = "172.168.3.69","172.168.3.99", "172.168.3.75"

$esxHosts = Get-VMhost
foreach($esx in $esxhosts){
$hba = $esx | Get-VMHostHba -Type iScsi
foreach($target in $targets){
if(Get-IScsiHbaTarget -IScsiHba $hba -Type Send | Where {$_.Address -cmatch $target}){
Write-Host "The target $target does exist on $esx" -ForegroundColor Green
}
else{
Write-Host "The target $target doesn't exist on $esx" -ForegroundColor Red
Write-Host "Creating $target" -ForegroundColor Yellow
New-IScsiHbaTarget -IScsiHba $hba -Address $target | Out-Null
Write-Host "done..." -ForegroundColor Green
}
}
}

  1. Drink a cup of coffee and come back in 5 minutes to find the job done.

You probably think I'm a pretty smart guy after writing script a like the one above. But you'd be dead wrong. I am an expert at cut and paste. There's a vast community of PowerCLI wonks who are more than happy to share their scripts. The one above actually comes from Arne Fokkema's site, ICT-FREAK.NL. (I'm sure he's a great guy and not at all a wonk!)

The value of automation
The one thing you learn as an instructor is the importance of automated builds. If you ever attend a training course where the instructor built the classroom environment, it's always a hot topic -- because, historically, this task always falls into the category of unpaid overtime.

Instructors quickly look to automate the classroom-setup process. At the same time, training course labs are normally consistent from one class to the next. So there's another huge advantage for standardization from Day One. As an old friend that used Unix once said to me, "If I done it twice, I've scripted it."

But it's also reasonable to use both PowerCLI and Host Profiles together. You could use PowerCLI as your main configuration and reconfiguration tool and use Host Profiles for consistency checks. Host Profiles has a validation process that can check if the host matches the host profile. You can run these checks on a weekly or monthly basis to see if any ad-hoc administrative changes were made to the standard build.

This was first published in May 2011

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.