Update a remote server to ESXi 5.1

With my new HaaS based home lab, I experience some limitations I need to live with. There is for example no way to insert a CD or DVD, nor can I use any USB key or a network boot.

That means that some of the procedures I have been using since long, need to be reviewed and updated. The next post describes one of the practical problems I encountered.

How do you remotely upgrade an ESXi server to version 5.1 ?

But as you can imagine, everything is “posh“-able. I was able to automate a manual procedure, and more important, I was able to upgrade my ESXi server to 5.1.

Short Intro

The hardware I used at home to develop and test my scripts finally reached the stage where it did not perform well enough to let me run all the components and scripts I wanted to use.

After some considerations, and a great tip from Andreas, I went for a solution similar to the one he described in his SBHVL posts. Make to sure to read his posts if you’re also in the market for a new and affordable home lab.

I now have a home lab that uses a Hardware as a Service (HaaS) environment.

In this and future posts I’m going to describe some of the scripts I use to manage and maintain this home lab. Since I don’t have any physical access to the lab, I will need to use different techniques then the ones I’m used to.

And since I’m very much into automation, I try to have all the interventions done through PowerCLI.

I hope you can use some of the scripts that will follow in this series in your own environments, or that they at least will give you some ideas how to automate some of your tasks.

The Update Method

The method that is used in the following script is not new.

The complete procedure is documented in the vSphere 5.1 documentation in the Upgrade manual, in the Update a Host with Image Profiles section.

The procedure was first described by Andreas in his How to update your (free / whitebox) ESXi server to ESXi 5.1 post. And later mentioned by William in his A Pretty Cool Method of Upgrading to ESXi 5.1 post.

But both posts require you to use a SSH connection and type in the esxcli command(s) from there. That is not really what we want to do in automation circles 😉

So this is my PowerCLI script that you can use to update your remote ESXi server to 5.1.

The Script

Annotation

Line 1-3: Connection information for the Connect-VIServer cmdlet

Line 4: The name of the datastore where the “depot” file is stored

Line 5: The folder that contains the “depot” file and the filename of the “depot”

Line 6: The serach string that will allow the script to select the required profile from the “depot”. This specific “depot” file for ESXi 5.1 contains 2 profiles, ESXi-5.1.0-799733-no-tools and ESXi-5.1.0-799733-standard. In the script we take the “standard” profile.

Line 8-9: Assemble the full path to the “depot” file.

Line 11-17: The esxcli command we will use has a number of parameters. Most of these are not needed for what we want to do, but to actually upgrade the ESXi host to 5.1, we need to set the “oktoremove” parameter to $true.

Line 23: Set the ESXi server in maintenance mode.

Line 25: From PowerCLI we use the Get-EsxCli cmdlet to set up an interface to the esxcli command.

Line 26-27: Get the full name of the “standard” profile.

Line 29-30: Prepare the upgrade process.

Line 32: Reboot the ESXi server to start the actual upgrade. At this stage you might see an error in the script. That’s caused by the fact that the server is rebooting while we still have active open connections from the script.

The Result

After the reboot, if all went well, the ESXi server will be running version 5.1. If there were problems, check the content of the log file at /var/log/esxupdate.log. It might contain some clues.

You will have to get the ESXi server out of maintenance mode.

Enjoy !

3 Comments

    vmcreator

    Fantastic work Luc 🙂

    Can this script be modified to apply the latest two Heartbleed patches for ESXi 5.5 ?
    ESXi550-20140404001
    ESXi550-201404020

    I have tried amending scripts, but it is confused ( or i am confused ) about depot profile names.

    Regards

    vmcreator

    William Lam

    Luc,

    Great article, but want to point out that you don’t need to use SSH to use ESXCLI, it’s available both locally on ESXi host as well as remotely. In my article I just wanted to show how you could directly patch from an ESXi host with just connectivity to VMware’s Repo.

    I agree for mass deployment, you’ll want to execute remotely connecting to the host and specify either VMware’s online repo, local internal repo or local offline depot.

    –William

      LucD

      Thanks for the clarification William.
      With the Get-EsxCli cmdlet it is quite easy to upgrade a large number of ESXi servers this way. You could even add some code to copy the depot file to a local datastore, if needed.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.