10 Replies Latest reply on Oct 5, 2010 12:08 PM by Mark Jeffery

    Trying to automate package creation

      I'm trying to work out how to automate creation of a BLPackage via blcli, but haven't found how to create some of the configuration items I've created in the UI.

       

      Basic workflow of the installation of the war file into a Sun Webserver:

       

      Stop the webserver (external command)

      Undeploy previous warfile (external command)

      Place warfile on the local filesystem

      Deploy warfile to webserver (external command)

      Perform various post install configuration based upon server properties ( 15 separate configuration entries)

      Start webserver (external command)

       

      I've got the external commands, and placing the warfile ok.  I'm adding the warfile as a depot file, then adding that to a blpackage.  Next adding external commands.  What I haven't figured out is how to add the post configuration items I need.

       

      Example of a configuration entry:

      Action:      Modify

      Path:         /app/actuate/SunOne/config/config.properties//downloadPath

      Name:       downloadPath

      Value0:     downloadPath

      Value1:     ??TARGET.WEBSERVER.DOWNLOAD_PATH??

       

      Am I missing something in the blcli help?  I'm not seeing how to add these except as a component, but I'm not sure that would help me in this since how I understand it would require a "target" server to have this already configured.  I'm hoping to have our build server to trigger a script to automatically create this script and deploy it in our dev/test environment.

        • 1. Re: Trying to automate package creation
          Bill Robinson

          I don’t know that you can do this w/ the blcli.

           

          You may need to create a dummy package first w/ this stuff already setup and then make copies and add the other items below.

          • 2. Re: Trying to automate package creation

            That's what I thought of first, but I haven't seen commands to re-order the steps.  Adding the depot file to an existing package seems to just put it at the bottom, but I need it at or near the top (within the first 3 lines).

             

            Other ideas on how to accomplish this?

            • 3. Re: Trying to automate package creation
              Bill Robinson

              you can add the external commands to the start or end but i don't see anything to re-roder the other object types.

              • 4. Re: Trying to automate package creation

                Since I hate when people don't update with what they eventually found, here's my current status:

                 

                I opened a support case and verified that currently the commands needed don't exist, but have created an RFE to provide commands to re-order package contents, and an RFE to enable blcli creation of configuration file entries.

                 

                So for now I think I'll work on having this as two separate packages, one containing the updated war files and the related external scripts, and another containing the post configuration.  I'm pretty sure I can create everything required in the 1st package, then link them together in a batch job.  I'll update once I have something concrete.  I really want to get this linked into our build system since our developers are resisting creation of the new packages, so it falls upon me.  :-)

                • 5. Re: Trying to automate package creation
                  John Van Ommen

                  Hey Mike,

                   

                  I think I worked on this one with you and Jim Allen back in 2007.  Back in the day, this was hard to do with BladeLogic, because you guys needed to update the contents of the BLPackage periodically.  And the problem with a BLPackage is that there was no easy way to do that in '07.  Six months later BladeLogic addressed that, by allowing you to deploy software via a URI instead of from the depot.

                   

                  I do almost everything with scripts here, because using Configuration Manager is like watching paint dry.  Here's how I would accomplish your task.  Bill may have a better way to do it, as he is an expert on BLPackages.

                   

                  First off, create a type 3 nsh script:

                   

                   

                   

                   

                  next...

                   

                  • 6. Re: Trying to automate package creation
                    John Van Ommen

                    After you've created the nsh script in the depot, you'll need some parameters for the script.  According to your post, you need to "

                    Perform various post install configuration based upon server properties ( 15 separate configuration entries)"

                     

                    The way that I do it is via using one script to set the parameters on the script that is in Configurion Manager.  For instance, if I wanted to set a parameter named "yourparameter" on the script which lives in the depot, I would do it like this:

                     

                    'NSHScriptJob','addNSHScriptParameterValueByGroupAndName',[JOB_GROUP,JOB_NAME,0,"yourparameter"]

                     

                    The thing that I like about doing it this way is that I don't have to log in to CM.  I can set those parameters from a web page, from the command line, or even a cron tab.

                     

                    For instance, if you wanted to deploy your application at three in the morning, you could stick that command into a Jython or nsh script on the app server, schedule it for three in the morning, and then you don't have to do the deployment of the war file manually.

                     

                    Note that the target of the 2nd script is the application server itself, or better yet, a load-balanced VIP for a cluster of application servers.

                     

                    The next step is...

                     

                    • 7. Re: Trying to automate package creation
                      John Van Ommen

                      Once you've created a type 3 nsh script in the depot, and a job to match it, it's time to work on the Jython script itself.

                       

                      The first thing you want to do is stop the webserver.  In Jython, you need to import the "OS" package, and then you can run any system commands like this:

                       

                      # Change this to wherever nexec is on your app server

                      nexec="/usr/bin/nexec"

                      # We're pulling the deployment target from a parameter on the type 3 nsh script

                      WarTarget=sys.argv[1]

                      # this is the name of the shell script on your TARGET that shuts down the webserver

                      ShutdownCommand = "/yourapp/bin/shutdown.sh"

                      cmd = nexec + WarTarget + ShutdownCommand

                      # Now that we've assembled our command with a combination of variables from the Jython

                      # script, along with parameters from Configuration manager

                      os.system(cmd)

                      We undeploy the previous warfile using similar syntax as we use to shut down the web server.  Basically, the commands are run via nexec, but the parameters live in CM

                       

                      Then we copy our content with something like this:

                       

                      # Change this to wherever nexec is on your app server

                      scp = "/usr/bin/scp"

                      cmd = scp + "/depot/mywarfile" + WarTarget

                      # Now that we've assembled our command with a combination of variables from the Jython

                      # script, along with parameters from Configuration manager

                      os.system(cmd)

                       

                      The post-install configuration, like the steps above, is basically the same process.  You can insert any parameters that you would like into the Jython script, by referencing the parameters using sys.argv[].

                       

                      Starting the web server is the exact same way as shutting it down, but change a single command.

                       

                      Let me know if this makes sense.  I installed Jython in your environment four years ago, and the version that you have includes all of the commands that you need.

                      • 8. Re: Trying to automate package creation

                        Hey John, good to hear from you.  Guess you kinda lost me on the jython script.  The problem I have is in modifying config files after the warfile is deployed.  If I'm just going to sed those in an external script, what's BL really doing in this?  The real benefit I see is it's ability to modify config files.

                         

                        What do you mean by deploying via a URI?

                         

                        I definitely agree about the UI, while performance of the UI has improved with SP5 it's still much less than 7.6.  I'm still getting complaints from the other users.

                        • 9. Re: Trying to automate package creation

                          Worth checking out Appendix D of the User Guide. There is a content format for defining content with an XSD (I had to log a support call to get hold of it).

                           

                          content can include templates with compliance rules!!!!, and packages etc.

                           

                          In 8.0 it is in early stages, but I think this is the future.

                           

                          Mark.

                          • 10. Re: Trying to automate package creation

                            I've since found out from closer reading that Appendix D of the User Guide doesn't quite manage to automate creation of a BlPackage.

                             

                            What I would do is to create a component template that refers to the WAR file as a file (perhaps using a local property so that it can be placed anywhere), and a local config object that points to a generic version of the config file which can be just one line (assuming name=value grammar)

                             

                            downloadPath=??TARGET.WEBSERVER.DOWNLOAD_PATH??

                             

                            Once the template has been made, then you can create a component on the DEV server, and then add that component to your BlPackage. This will include the WAR file AND the config file change.

                             

                            Mark.