Installing and/or upgrading VMware tools has always been a bit more complicated for Linux guests than for Windows guests. After the installation of the package binaries, the vmware-config-tools.pl script must be run to configure the tools for your environment. This script has to be run from the console, which is a pain when you’ve got more then just one or two Linux VMs. And may the good Lord help you if the modules aren’t suitable for your running kernel and you don’t have a compiler (or the C header files for your running kernel) already installed.
When VMware added the Automatic Tools Upgrade …
The situation certainly improved, but it is by no means a fool proof solution. In my experience, it doesn’t work 100% of the time for Linux guests (though this *could* be due to the heavy modification I’ve done in my distro). And furthermore, what if you want to automatically upgrade 100’s of Linux guests, not just one? Or what if you’ve already got a deployment tool that you’d like to use to push the tools out? (Kind of tough when the script needs to be run directly in the console)
So, I looked to see if there was a way to improve the situation. First, I needed to find a way to run vmware-config-tools.pl remotely in an automated fashion. And by the way, it’s not that you can’t run this script remotely via SSH because you can. The problem is that when you do so, you immediately get following question …
It looks like you are trying to run this program in a remote session. This program will temporarily shut down your network connection, so you should only run it from a local console session. Are you SURE you want to continue?
Unfortunately, to run vmware-config-tools.pl remotely, we need to include the –d flag so that the script will automatically select the default answers to all of the questions for us. And the problem is, the default answer to this question is “no.”
So I looked through the vmware-config-tools.pl and I found that it’s really only checking to see if the SSH_CONNECTION environment variable is set. Well, that’s easy … simply executing vmware-config-tools.pl in a different shell allows us to side step this.
Next I just created a simple bash script that gets pushed out to the /tmp directory along with the vmware tools installation package (also pushed to the /tmp directory) and gets executed remotely by my deployment tools (which for me are are just more bash scripts, but this should work with any enterprise deployment tool). Here’s the simple script I used for my guests …
#!/bin/bash
RPM=`ls /tmp | grep VMwareTools`
rpm -e VMwareTools
echo "Old VMwareTools removed" > /tmp/vmware_tools_upgrade.logrpm -i /tmp/$RPM
echo "$RPM installed" > /tmp/vmware_tools_upgrade.logsh -l root -c /usr/bin/vmware-config-tools.pl -d
echo "vmware-config-tools.pl -d executed" >> /tmp/vmware_tools_upgrade.logservice vmware-tools restart
echo "vmware-tools restarted" >> /tmp/vmware_tools_upgrade.logservice network restart
echo "network restarted" >> /tmp/vmware_tools_upgrade.logexit
This is obviously a very basic script and could easily be enhanced with better logging and error handling. Also, for Debian distros, such as Ubuntu, you’d need to modify this script to handle the tar.gz installation package … unless, of course, you’ve modified your distro to handle RPMs (as I have).
The good news is that, at least for my environment:
- This works 100% of the time and a restart of the VMs is not necessary.
- I no longer have to upgrade many guests by hand.
However keep in mind, there is still a network outage during the upgrade (usually just about a minute or two), so be sure to continue using a maintenance window for your upgrades.
-
nate