Puppet, from PuppetLabs, is a popular open source configuration management utility used for infrastructure configuration and IT automation. It provides a wealth of capabilities for provisioning virtual machines, managing patches, configuration management etc. This is a quick guide on using the Puppet module for WebSphere Liberty.

We’ll see how to provision a virtual machine running Ubuntu Linux, install Liberty into it, create a server and deploy a web application on the server. We’ll make use of Vagrant, VirtualBox, and Puppet using the Puppet module for the WebSphere Liberty Profile.

The Puppet module for WebSphere Liberty that we’ll use in this article is a work in progress. There are many features that we’re looking to implement and we welcome feedback by GitHub issues.

Download and install the required software to your workstation

  • Install Vagrant – a tool for simplifying the management of virtual machines and what is provisioned into them.
  • Install VirtualBox – virtualization software that runs on Max OSX, Linux, Windows and other operating systems.
  • Install Git – the open source source distributed version control system. If you’re using Windows, the download will include the Git-Bash command line tool.

Accept all the default options when installing those products. If you use Windows, you also need to set your editor, for example, to use WordPad. At a command prompt enter:

setx EDITOR "%ProgramFiles%Windows NTAccessorieswordpad.exe"

Initialize the Vagrant and VirtualBox environment

In a bash terminal window (Git Bash if you’re using Windows) create a directory. This is where we run Vagrant from. We’ll call it VAGRANT_DIR from now on. In that directory execute the following commands:

vagrant init ubuntu/trusty64
vagrant up

When vagrant up runs for the first time, the virtual machine with an Ubuntu Linux guest OS will be downloaded from the HashiCorp Atlas site. This will take a few minutes. You can now SSH into the machine using:

vagrant ssh

Type Ctrl-D to come out of the SSH session. You can find out more at the Vagrant Docs site.

Download Liberty and its Puppet module

We’re going to install Liberty into the guest OS running in the VM. Then add to that, a sample web application. The Puppet module for Liberty will do this for us. Puppet will get the binaries from the VAGRANT_DIR so first download the following into the VAGRANT_DIR:

  • WebSphere Liberty Profile Runtime Use the first ‘Download’ button. This requires you to accept the license. The latest version at the time of writing is wlp-developers-runtime-8.5.5.4.jar. Create a directory in VAGRANT_DIR called installables and put the jar in there.

The other downloads can be done from the Git Bash command line:

  • JSP examples application from Maven Central. From within Git Bash in the VAGRANT_DIR execute:
    curl -O http://central.maven.org/maven2/org/apache/geronimo/samples/jsp-examples-war/3.0-M1/jsp-examples-war-3.0-M1.war
    
  • WebSphere Liberty Puppet module from GitHub. First create the modules directory inside VAGRANT_DIR then clone the Git repository into the modules directory naming it wlp on the way:
    mkdir modules
    git clone http://github.com/WASdev/ci.puppet.wlp.git modules/wlp
    

Provide configuration for Liberty

The JSP Examples application is simple enough that just putting it in the Liberty server’s dropins directory is enough to get it working. But we’re going to show how to configure it with a server.xml. Create a file in VAGRANT_DIR called jsp-examples-war-3.0-M1.xml with the following content:

<server description="JSPExamplesServer">

<!-- Enable features -->
<featureManager>
  <feature>jsp-2.2</feature>
  <feature>servlet-3.0</feature>
</featureManager>

<application id="jsp-examples-war-3.0-M1" name="jsp-examples-war-3.0-M1" location="jsp-examples-war-3.0-M1.war"/>

</server>

Provide configuration for Puppet

We’re going to use the wlp module we got from GitHub, in a Puppet manifest. Within VAGRANT_DIR, create a manifests directory and a default.pp manifest within it:

class { "wlp::install_java":} ->
class { "wlp":
  appNames => ['jsp-examples-war-3.0-M1.war',],
  puppetFileRoot => "/vagrant",
  serverBinaryName => "wlp-developers-runtime-8.5.5.4.jar",
  standalone => true,
  acceptLicense => true,
  java_home => "/usr/lib/jvm/java-7-openjdk-i386",
  appsDirName => "."
}

Configure Vagrant to provision Puppet and run the manifest

The Puppet provisioner for Vagrant runs Puppet in the guest. It picks up manifests/default.pp by default but needs to be configured with the location of the required modules. Add the following to the Vagrantfile immediately before the last end statement:

config.vm.provision "puppet" do |puppet|
  puppet.module_path = "modules"
end

The JSP Examples application is served up on the URL http://localhost:9080/jsp-examples-war-3.0-M1 in the guest OS. To access this from a browser in the host, we need to configure port forwarding like this in the Vagrantfile:

config.vm.network "forwarded_port", guest: 9080, host: 8080

Provision the guest

Run vagrant up to start the VM and run the Puppet provisioner. This will install Liberty, create a server and install the JSP Examples application.
Now you can go to http://localhost:8080/jsp-examples-war-3.0-M1 in a browser to see the application running in the guest.

You can see that with a small piece of configuration it is possible to reliably and repeatably deploy Liberty and an web application using the Puppet configuration management software.

6 comments on"Introducing the Puppet module for WebSphere Liberty"

  1. Hello,

    Does puppet as auto discovery future to capture all the changes after the initial install for websphere application server? Please let me know if I need to elaborate my question.

    Thanks

    Santhil Murugesan
    Daimler Trucks North America

  2. This is excellent. Puppet users will be excited to see support for Websphere Liberty. Is it possible to publish this module on the Puppet Forge (https://forge.puppetlabs.com/). Thanks!

  3. We are very interested to leverage Puppet to deploy Liberty profile but without Vagrant presence. Where should I place the sample application and sample server.xml in this case? Thanks, Jeffrey

    • Hi,
      Thanks for your interest.If you are using puppet module for liberty without vagrant.The following is the structure you would need to place your apps,dependencies and server.xml files.

      1) /wlp/files – location to place your wlp installables

      2) /wlp/files/apps – location for your apps. If your app is named SampleApplication.war (or any other extension) then you need to have your application’s deployment xml or corresponding additions to server.xml as SampleApplication.xml

      The module takes care of automatically copying both the application and its corresponding server.xml extension based on the definition in site.pp

      3) /wlp/files/dependantLibs – If your application has dependencies like 3rd party libraries they can be placed in this directory.

      The base server.xml is taken from /wlp/templates.

      assuming typically /etc/puppetlabs/puppet/modules/

      We are having a more another article coming up soon that would describe this in greater detail.That should clarify a lot of things.

      Regards
      Anil

Join The Discussion

Your email address will not be published. Required fields are marked *