Product Development in Brisbane

Automating Deployment to IBM WebSphere Portal

Having an automated deployment procedure is an important goal for any project. This post talks about the the steps taken in making E2 autodeploy to WebSphere Portal in Development.  The below process assumes that the application has been deployed once through other means.

After a friendly pointer from AJ to an article about automating websphere deployment, I decided that the time had come to revisit trying to automate the deployment of our EAR file for E2. I had done bits and pieces of thi in the past using a combination of the WebSphere scripting client, and the WebSphere ant tool (like ant but built with WebSphere bits and pieces). The killer constraint for me is that my client machine didn’t have access to any of the WebSphere binaries (perhaps unsuprisingly Apple and IBM have don’t perfectly interoperate).

In order to work around thi sproblem I ended up leveraging one of the classic protocols (telnet), the websphere scripting client, samba (to mount the application server drives), and a bit of ant to glue it all together. The process outlined below is focused around the deployment of the application E2Application to WebSphere portal.

Step 1: Enable telnet

In Windows Server 2003 this is relatively straightforward. Simply go to your control panel -> services -> Telnet go to the properties, make it automatic and start it.

Step 2: Write scripts to start and stop the app server

I did this using tcl and ended up with the following scripts (the pythonistas may like to use jython to do the same):

stopApplication.jacl  

set cell [$AdminControl getCell]
set node [$AdminControl getNode]
set appManager

   [$AdminControl queryNames
   cell=$cell,node=$node,type=ApplicationManager,process=WebSphere_Portal,*]
$AdminControl invoke $appManager stopApplication E2Application

startApplication.jacl  

set cell [$AdminControl getCell]
set node [$AdminControl getNode]
set appManager

    [$AdminControl queryNames
   cell=$cell,node=$node,type=ApplicationManager,process=WebSphere_Portal,*]
$AdminControl invoke $appManager startApplication E2Application

Step 3: Write the ant code to compile and copy the application

After the series of standard building tasks, we used a simple copy task to copy the files to the exploded WAR directory on the server. (something like: ${portal.home}/WebSphere/profiles/wp_profile/installedApps/{cell}/{application}.ear/{app_war}.war). Since I develop on a laptop I added in a combination of available and fail task to stop me from accidently creating directories if I hadn’t mounted m

Step 4: use ant to telnet to the server

Make use of the telnet ant task1 to telnet into the server, and run the stop and start server jacl scripts. My Ant targets (passwords scrubbed) are below (excuse the duplication):

<target name="startApplication">
   <telnet userid="Administrator" password="${portal_admin_password}" server="${portal_server}">
   <read>Administrator</read>
        <!– change to the IBM AppServer directory –>
        <write>cd \ibm\AppServer\bin</write>
        <read>AppServer\bin</read>
        <!– Execute the jacl –>
        <write>wsadmin -conntype SOAP -port 10033
                -username wasadmin -password **** -f startApplication.jacl
        </write>
        <!– wait for the connected to process message, which will occur on the successful completion of the script –>
        <read>Connected to process</read>
        <read>AppServer\bin</read>
    </telnet>
</target>


<target name="stopApplication">

    <telnet userid="Administrator" password="${portal_admin_password}" server="${portal_server}">
        <read>Administrator</read>
        <!– change to the IBM AppServer directory –>
        <write>cd \ibm\AppServer\bin</write>
        <read>AppServer\bin</read>
        <!– Execute the jacl –>
        <write>wsadmin -conntype SOAP -port 10033
                -username wasadmin -password **** -f stopApplication.jacl
        </write>
        <!– wait for the connected to process message, which will occur on the successful completion of the script –>
        <read>Connected to process</read>
        <read>AppServer\bin</read>
    </telnet>
</target>

Step 5

mix ingredients and enjoying being able to have a one click deploy to WebSphere Portal.

Appendix

For security paranoid people with time on their hands, it is possible to do this using ssh and scp. The key parts will be step 3 and step 4. In step 3 we are using folder share and the ant copy task currently. It could be done with scp. In step 4 the use of telnet could be replaced with ssh.

1 - The telnet task depends on the availability of the commons-net jar on the classpath. (click here to download commons-net).

6 Responses to “Automating Deployment to IBM WebSphere Portal”

  1. Adrian Sutton Says:

    This script (and the assembled one* in ~aj/deployE2/ ) however doesn’t handle mapping resources like databases so you wind up with a rather blank E2 and have to deploy manually. I wonder if the magical fairies could fix that…

    *Rob’s blog - bringing a bit of IKEA to your life… :)

  2. robert Says:

    you’ll probably find that it works well for updates — not quite as well for first time deploys…. and that it might take a bit of work for the magical fairies to make things work the way you want :)

  3. Adrian Sutton Says:

    That was an update sadly. My magical fairies are looking a little buggy. :P

    I’m not stressed about it though, but it would be good to sort it out - the initial manual install process still needs work and documentation, it doesn’t really have a good starting point at the moment.

  4. robert Says:

    hmmm…

    as fun as it is to have conversations with people I’m currently working with on my blog, I think I’ll pick up this thread elsewhere… if magical fairies produce outcomes there might be a follow up entry.

  5. robert Says:

    The fairies say — RTFM (read the fairy manual) — "copy the files to the exploded WAR directory". Unfortunately unzipping an ear doesn't also unzip the embedded war. so unzipping an ear file to the exploded EAR directory != to copying files to an exploded war directory. Given that the choice of work for the fairies today might be between fixing this, and doing documentation, you might get some help :).  In additon, copying the contents of the ear over the top will almost certainly result in the IBM deployment files being overwritten, which is a bad thing, and will cause additional problems.

  6. Adrian Sutton Says:

    Bloody picky fairies… What’s the difference between EAR and WAR anyway? You have one and the other gets chopped off - it’s all related.

    On the plus side, it appears to work now. Though for the life of me I can’t remember what the previous version number was so it might just be a no-op. Doing nothing is better than breaking everything though. :)

Leave a Reply