Automating patch installation on XenServer
Automating patch installation on XenServer
I have four instances of freshly installed XenServer 6.2 and there are about a dozen patches for each that need to be applied. Herein, I will attempt to somewhat automated the application of these patches.
What you will need to know:
The list of patches required
The URLs of the download pages for each patch to be applied
The UUID of the patch
The UUID of the Target Host. This can be found by doing, on the console,
a:
xe host-list
The procedure is as follows:
Use the wget command to download the patch. I’ll use Service Pack 1 as an example. We want that patch first, as it is cumulative, and will cut down the number of other patches to be installed.
To find the URL where SP1 resides. go to XenCenter Console, Tools, Check for Updates. This will give you a list of patches available for your server, with links to the download location. Click on the link for XS62ESP1. On the web page that opens, click on “Download”. This will open another page. This is the URL that you want. Copy it to clipboard.
You’ll need the urls and filenames for all the applicable patches when you customize your script.
http://downloadns.citrix.com.edgesuite.net/8707/XS62ESP1.zip
Now initiate the wget command at the console in XenCenter using this URL:
wget http://downloadns.citrix.com.edgesuite.net/8707/XS62ESP1.zip NOTE:Case Sensitive!
Then unzip it:
unzip XS62ESP1.zip
This zip file contains a file ending with the extension “xsupdate” as in “XS62ESP1.xsupdate. That’s our patch
Register the patch on the Target Server:
xe patch-upload file-name=XS62ESP1.xsupdate
This will display the uuid of the patch. We’ll need that for the next command. You can call it up again with:
xe patch-list
Install the patch:
xe patch-apply uuid=<The patch uuid from th xe patch-list command> host-uuid=<The host uuid from the xe host-list command>
Due to limited disk space, we’re going to clean out our working directory:
rm *
Now we’ll write our script: Notice that we’re doing the upload/registration and apply in one command.
Start of Script:
wget http://downloadns.citrix.com.edgesuite.net/8707/XS62ESP1.zip
unzip XS62ESP1.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/8737/XS62ESP1002.zip
unzip XS62ESP1002.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1002.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/9058/XS62ESP1005.zip
unzip XS62ESP1005.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1005.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/9491/XS62ESP1008.zip
unzip XS62ESP1008.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1008.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/9617/XS62ESP1009.zip
unzip XS62ESP1009.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1009.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/9698/XS62ESP1011.zip
unzip XS62ESP1011.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1011.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/9703/XS62ESP1013.zip
unzip XS62ESP1013.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1013.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/9708/XS62ESP1014.zip
unzip XS62ESP1014.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1014.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/10128/XS62ESP1015.zip
unzip XS62ESP1015.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1015.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/10134/XS62ESP1012.zip
unzip XS62ESP1012.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1012.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
wget http://downloadns.citrix.com.edgesuite.net/10174/XS62ESP1016.zip
unzip XS62ESP1016.zip
xe patch-apply uuid=`xe patch-upload file-name=XS62ESP1016.xsupdate 2>&1|tail -1|awk -F” ” ‘{print $NF}’` host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’`
rm -f *
Now just copy the text you created with your patches listed in place of mine and paste in to to the console. You’ll be off and running! (Go get Coffee)
Matt Long
02/17/2015