Automation 101 – VMware Tools with Orchestrator

We’ll skip the reason you need tools installed. We’ll also skip a bit on the other ways to do this in PowerCLI. Rather, we’ll bring you a way to do this in Orchestrator.

Note:

If you’re not using vCO, you should be. Why? I covered that here. Additionally, there are some excellent vCO resources here.

VMware Tools Workflows

vCO ships with four workflows for managing VMware tools:

  • Mount tools installer
  • Unmount tools installer
  • Upgrade VMware tools
  • Upgrade VMware tools at next reboot

All of these are found in the vCenter library of workflows that rolls with the vCenter plug-in. Specifically they’re found under “Library > vCenter > Virtual machine management > VMware Tools”

Mount/Unmount tools installer

These two workflows take a single VM as input and can be used when provisioning a new VM. In the case of Unmount, they are also useful in ensuring a VM does not have the tools installer mounted before a VMotion. The real power with these two comes in your ability to use them as a part of a larger workflow however.

The mount and unmount workflows both have identical schema and an identical amount of code in their scripting blocks. Let’s take a look at each:

Schema

image

Code

vm.mountToolsInstaller();

vm.unmountToolsInstaller();

A bigger workflow

Well, I said the power in this was when you wanted to do more than a handful of VMs right, so here’s the bigger workflow promised:

image

Lots of little cross-wise lines, etc. Working around the workflow:

  • Get a list of everything
  • Make sure we have VMs left to parse
  • Set the active VM
  • Is it powered on?
    • If not, increase the count, start from step 2
    • If yes, should we mount or unmount the tools?
      • If yes, mount em, continue
      • If no, unmount the tools and continue

Confused? Well, I’ll spare the additional code as you can likely figure it out, and have uploaded the completed workflow here.

Upgrade Tools (on next reboot)

The next two in our list are the upgrade tools workflows which more or less function like their PowerCLI counterparts mentioned above. The first has a really really simple schema, so we’ll skip it. The more interesting one is “on next reboot”:

image

Of this, the more curious part is what’s going on behind the “Upgrade Tools” bit:

if (vm.summary.guest.toolsVersionStatus != “guestToolsNeedUpgrade”) {
    System.log(“Tools do not require upgrade for vm: ” + vm.name);
}
else {
    System.log(“Upgrading tools for vm: ” + vm.name);
    task = System.getModule(“com.vmware.library.vc.vm.tools”).upgradeToolsAtNextReboot(vm);
}

Do I need an upgrade? OMG Yes I do, send a call to the vCenter API to upgrade the tools at next reboot. Or so. This too could be worked into a larger workflow like we did before. That said I’ll leave it as an exercise for the end user this time.

Summary

Is vCO awesome? You bet! This time around we mounted and unmounted your VMware tools, and set the tools to upgrade at the next VM reboot, you know, in case you don’t have a maintenance window.

As always, if you have any questions drop a line in the comments or hit me up on twitter here.

4 thoughts on “Automation 101 – VMware Tools with Orchestrator

  • Hi ,
    We have 800 VMs  with different build number VMware tools.Is this process will  work for my environment.

    Regards
    Surya

  • As your environment is unique to you, and while I’ve written the workflow in a way that “should” work. I strongly recommend you test this in a lab first as this will be making changes to software installed on your VMs and potentially rebooting them as well. You wouldn’t want to inadvertently cause a resume producing event.

  • Check this link for an option to change this setting – easily configured through vUM.

    http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.vsphere.update_manager.doc%2FGUID-6F8C3BEF-7269-471A-8536-D3F782226C30.html

    *********************************************************************************
    To enable upgrading of VMware Tools on power cycle, use one of the following options.

    On the Home page of the vSphere Client , select VMs and Templates and click the Update Manager tab.

    Select a virtual machine or a container object from the inventory.

    Click VMware Tools upgrade settings.

    In the Edit VMware Tools upgrade settings window, select the check boxes of the virtual machines for which you want to enable VMware Tools upgrade on power cycle.

    Click Apply.

Comments are closed.