Friday, March 28, 2014

Packaging IBM Data Center Client (DB2COPY1) 10.5 for SCCM

This bugger was fun. I only say that because it wasn't cut and dried like most packages are. Looking through Google, IBM doesn't have the best reputation when it comes to software deployment. My previous experience was with ClearCase and ClearQuest. Thankfully, another group handled the headache of building the scripts and answer files. I just had to dump them in SCCM.

But this one is all on me, so here's how it went.

The goal was three deployment types. One for a fresh install, one for an upgrade install, and one for development/testing purposes. The client provided a zipped up file that contained the install files and a Word doc of the step-by-step manual install instructions. After perusing the instructions, I found that the installer generates an answer file that can be used for silent installs. Wonderful! Off to Google I went for syntax and usage. I Googled for "IBM Data Server Client silent install" and the links took me straight to IBM's knowledge base. Two articles stood out. One on the command line usage of db2unins (the uninstaller) and one on where to find the sample response files. The sample files are at [InstallSource]\db2\Windows\samples. Because links change, I will not be adding any here. The Google search above should suffice. Take note, however, that using the MSI installer WILL NOT work if you want to use the response file. It doesn't recognize it!

My install answer file (PROD_CLIENT.rsp) ended up being pretty simple. You can open and edit the file with notepad. This was mine (revised 4/22/2014 to show the Extended Security option is set to No):

PROD_CLIENT.rsp File

PROD=CLIENT
LIC_AGREEMENT=ACCEPT
FILE=C:\Program Files\IBM\SQLLIB\
INSTALL_TYPE=TYPICAL

LANG=EN

KILL_PROCESSES=YES
INSTANCE=DB2
DB2.NAME=DB2
DEFAULT_INSTANCE=DB2
DB2.TYPE=CLIENT
DB2_EXTSECURITY=NO
DB2_COPY_NAME=DB2COPY1
DEFAULT_COPY=YES



I saved this file and put it in the db2\Windows folder of my install source. The uninstall answer file is necessary if you want to do a completely silent uninstall, which I did. This file is called db2un.rsp and is also in the samples folder. This was the final version of the answer file I used:

db2un.rsp File

KILL_PROCESSES = YES
REMOVE_PROD = ALL
REBOOT = NO


This file was also saved to db2\Windows in my install source.

Additional steps in the provided documentation from my client said that the services file in C:\Windows\system32\drivers\etc needed to have entries added. The entries were different between the Production install vs. the Development/Testing install. I found a vbscript via Google again that appends the services file. I made two copies of the .vbs file, one for Production and one for Development/Testing. Here is the .vbs file contents and you can see where I added my info on the iReturnValue line:

set_prod_svc.vbs File

Option Explicit
On Error Resume next

Dim fso
Dim WinDirPath
Dim PathToHosts, PathToServices
Dim iReturnValue
Const TAB = " "
Set fso = CreateObject("Scripting.FileSystemObject")
WinDirPath = fso.GetSpecialFolder(0)
PathToHosts = WinDirPath & "\system32\drivers\etc\hosts" ' path to file
PathToServices = WinDirPath & "\system32\drivers\etc\services"

'iReturnValue = WriteToFile (PathToHosts, "127.0.0.1","localhost","","")
iReturnValue = WriteToFile (PathToServices, "[databasename]","446/tcp","","#DB2 Mainframe")


Set fso = Nothing
'--------------------------------------------------------------------------------------------------
' Description :Function to write to file
' Return Value :1 if changes made
' 0 if file doesnt exist
'--------------------------------------------------------------------------------------------------
Function WriteToFile (ByVal pathToFile,byval para1,byval para2,byval para3,byval para4)
Dim TempFile
Dim msg

If fso.FileExists(pathToFile) Then

Set TempFile = fso.OpenTextFile(pathToFile,8,True)
msg = para1 & TAB & para2 & TAB & para3 & TAB & TAB & para4
msg = rtrim(msg)
TempFile.WriteLine msg
TempFile.Close

Else
WriteToFile = 0
End If

End Function


Again, these two files were saved to db2\Windows on my install source.

After the install is completed, configuration of the client is required. Digging through IBM's site, they recommended creating a .bat file with your db2 commands and calling that file with db2cmd. Below is an example of my db2 configuration, which I saved as prod_db2_catalog.bat. Two other versions were made for the upgrade, which uncatalogs the old settings and sets the new ones and the other for development/testing, which used different servers. Here are the contents of my file (items in brackets will be specific to your environment:

db2 catalog tcpip node [nodename] remote [remotename] server [servername]
db2 catalog database [databasename] at node [nodename
db2 terminate
exit


One more, the files were saved to db2\Windows on my install source.

Since we have to do several tasks, I made a .cmd file to encompass all that needs to be done. Three different versions were made depending on Production, Upgrade, and Development/Testing because each called the relevant .vbs file to set the services and the relevant configuration .bat file. Here is my install_db2_prod.cmd file (revised 4/22/2014 to include applying a license):

install_db2_prod.cmd File

@echo off
Set PATH=%SystemRoot%;%SystemRoot%\system32

ECHO Append services file
"%~DP0set_prod_svc.vbs"
TIMEOUT 5

ECHO Install New Version
md C:\IBM_Install_Log
ECHO Installing...please wait...
"%~DP0setup.exe" "%~DP0PROD_CLIENT.rsp"
TIMEOUT 5

ECHO Configure Client
;Licensing
copy /y %~dp0db2consv_zs.lic "C:\Program Files\IBM\SQLLIB\BIN"
CMD /C %~dp0DB2_set_license.bat

;Database "C:\Program Files\IBM\SQLLIB\BIN\db2cmd" %~dp0prod_db2_catalog.bat

goto exit

ECHO Completed!
:exit
exit


While the TIMEOUTS aren't really necessary, I kept them in there just in case there was a timing issue between each task. In my testing, this never occurred, but my environment had older machines out in the wild. You will notice I used %~DP0. This is necessary when calling a command or batch file in SCCM.

A license needs to be applied. It's a very simple command, which I also made into a separate batch file and called in the install file.

DB2_set_license.bat

@echo off
ECHO Set DB2 License
C:
cd "C:\Program Files\IBM\SQLLIB\BIN"
db2licm -a db2consv_zs.lic

ECHO Licensing complete!
TIMEOUT 5

One last file needed to be made for the uninstall. This was the most challenging and frustrating part of my endeavor because when you run the command as documented, an annoying message of "The system was unable to locate the file path." would occur AFTER the command completed. It made absolutely no sense, but, it also caused the script to show a failure even though there really wasn't one. While there's more than one way to address the error so that the script would continue, I set up the Deployment Type in SCCM to accept Error 1 as a "good" return code. Calling the command line in the SCCM Deployment Type would not work because it didn't like %~dp0 no matter what I tried, so I created another command file called uninstall_all.cmd. It copies the answer file to the root of C:\ and then runs the uninstall command. Here are the contents of the file:

uninstall_all.cmd File

copy /y %~dp0db2un.rsp C:\

"%PROGRAMFILES%\IBM\SQLLIB\BIN\db2unins" -y -u C:\db2un.rsp
TIMEOUT 5
goto EXIT

:EXIT
exit


This last file was also saved in the db2\Windows folder of my install source.

Now that all the files have been created and are in place, I can created my SCCM Application. Here are the steps of going through the Create Application Wizard.

  1. Choose Manually specify the application information and click Next.
  2. Enter a name for the package and any other information you wish to include. Only the name is required. The rest is optional. Click Next.
  3. If you use the Application Catalog feature, add the necessary information to this screen, otherwise, skip and click Next.
  4. At Deployment Types, click Add...
  5. In the drop down list next to Type: change to Script Installer and click Next.
  6. Give the script a name (example: Install Production) and click Next
  7. Browse to your source location for the files. This is typically a network location. I set this to the root of my install source location.
  8. Next to Installation program: click the Browse... button and locate the command file in db2\Windows you wish to use. Change to All Files (*.*) so you can see all files instead of just .exe files then find your command file. In this example, I'm using install_db2_prod.cmd.
  9. Next to Uninstall program: click the Browse... button and locate the command file in db2\Windows. Change to All Files (*.*) so you can see all files instead of just .exe files then find your command file. In this example, I'm using uninstall_all.cmd
  10. Check the box next to "Run installation and uninstall program as 32-bit process on 64-bit clients and click Next.
  11. In Detection Method, click Add Clause...
  12. Change Setting Type: to Windows Installer. Click the Browse... button and select IBM Data Server Client.msi and click OK. Click Next.
  13. Set Installation behavior: to Install for system. Set Logon requirement: to Only when a user is logged on. Set the Installation program visibility to your preference (I used Minimized). Check the "Allow users to view and interact with the program" box and click Next.
  14. I did not set any Requirements or Dependencies, so simply click Next through the last three windows and click Close when the wizard is completed.
  15. Back in the Create Application Wizard, click Next twice to complete the build of the Application and click Close when done.
  16. You are now ready to distribute the content, create your collection according to your environment, and create a deployment.

As part of my troubleshooting to get all of this working, I used PSExec on my test machine. This allowed me to modify the command files directly on the test machine without having to update content and try the deployment again. When all was done, I copied my finalized files to my install source location, then updated the content and ran all of my deployments again to validate they worked. This is the article I used:

http://blogs.technet.com/b/ryanan/archive/2013/11/06/configuration-manager-package-preparation-guide-for-app-owners.aspx

I hope this has helped you with your build and deployment of IBM Data Center Client!