CyberGround

Install VMWare vSphere SDK for Perl to Debian 9

Home Blog Categories Links

Install VMWare vSphere SDK for Perl to Debian 9

Darwick 2018-08-23 Categories: #automation #perl-sdk #vmware

As you can see in my previous post, installing VMware vSphere SDK for Perl 6.5 or 6.7 to a CentOS (or any RHEL) 7 system is a pain in your ass. If you would like to install it any Debian (like Ubuntu) system it would be more difficult for you. This is the reason why I wrote this post, I will guide you through this operation.

First of all, you have no chance to use precompiled modules at all, but in this scenario, you don’t even need to use CPAN and compile modules. All modules can be installed via apt, but you will need to modify some Perl scripts (even the installer). After you did it, your SDK scripts will work without issues.

I have tested this in the latest Debian 9 Stretch (64bit) VM with vSphere SDK for Perl 6.5 and 6.7, fresh and clean installs, only the necessary packages was installed, but I’m pretty sure that it will work with the lower Debian 8.x (Jessie) versions or the upper 10.x (sid) versions as well as the Ubuntu latest 16.x (Xenial)

Optional – If you plan to install the SDK for Perl to a VM, then you should install open-vm-tools:

apt install open-vm-tools

First of all, upload the 64bit SDK for Perl to your server and unpack it. Assumed you have uploaded the packed content to your root directory, you can unpack it:

tar -xvzf VMware-vSphere-Perl-SDK-6.x.0-yyyyyyy.x86_64.tar.gz

and enter to the unpacked directory:

cd /root/vmware-vsphere-cli-distrib/bin/

Before you execute the installer, you will need to install the perl modules. This is the complete list, it will install all the dependencies you will need:

apt install perl perl-doc perl-modules-5.24 libssl-dev libxml-libxml-perl libcrypt-ssleay-perl libmodule-build-perl libarchive-zip-perl libpath-class-perl libdata-uuid-perl libsocket6-perl libio-socket-inet6-perl libnet-inet6glue-perl libdevel-checklib-perl libio-captureoutput-perl liblwp-protocol-https-perl

Before you run the installer, first modify this install script: /root/vmware-vsphere-cli-distrib/bin/vmware-uninstall-vSphere-CLI.pl

find line 2382 and 2410 (which are exactly the same) and replace this:

{‘module’ => ‘UUID’, ‘version’ => ‘0.27’, ‘path’ => ‘UUID-0.27’},

to that:

{‘module’ => ‘Data::UUID’, ‘version’ => ‘0.27’, ‘path’ => ‘UUID-0.27’},

if you are using Ubuntu, skip this step. Otherwise, find line 2283 and replace this:

if ( direct_command("cat /etc/*-release | grep -I ubuntu") || direct_command("cat /proc/version | grep -I ubuntu") ) {

to that:

if ( direct_command("cat /etc/*-release | grep -I debian") || direct_command("cat /proc/version | grep -i debian") ) {

Now you can execute the installer:

perl /root/vmware-vsphere-cli-distrib/bin/vmware-uninstall-vSphere-CLI.pl

and follow the steps. If everything goes well, the SDK for Perl will be installed as desired.

Now you need to modify this perl script /usr/share/perl/5.24.1/VMware/SSOConnection.pm

find the line 27 and replace this:

use UUID;

to that:

use Data::UUID;

The installation is completed, but sadly, you will find that this will not work at all. If you try to run any script, you will see an error: Server version unavailable at https://your.vcenter.host/sdk/vimService.wsdl

I did try to find the answer, most of them suggested me to disable the ssl hostname verification, or downgrade the libwww-perl, but I did not wanted to do them. After a lot of googleing, I found the answer in VMWare community forum There is a lot of answers and suggestions, but I accepted which suggested me to switch from IO::Socket::SSL to Net::SSL

To make this happen, modify this perl script: /usr/share/perl/5.24.1/VMware/VICommon.pm

and after module loads (like in line 26) add this:

BEGIN {
$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
}

Save your changes. This script will be included by all of your other SDK scripts, so this solution will work for you. If you found any better solution to bypass the issue, then you can use them, ofcourse.

That is all, hope this helps to you. 🙂