DevOps Automation

 View Only

Creating components for use with the WebSphere Application Server – Configure plug-in

By Osman Burucu posted Thu January 05, 2023 09:44 AM

  

This article was originaly published in 2016.01.14

Creating components for use with the WebSphere Application Server – Configure plug-in

The WebSphere Configuration Discovery step in the WebSphere Application Server – Configure plug-in connects to WebSphere Application Server and retrieves configuration data. The configuration data is represented in JSON format and is stored in the stdOut.txt file that the step produces. The configuration data can be converted into templates for deployment to multiple environments.

This document describes creating IBM UrbanCode Deploy components to manage and apply these templates.

A sample application is included with the WebSphere Application Server – Configure plug-in, which includes sample components for reference.

Getting Started

After you convert configuration data into templates, the following folders are created in the templates directory. See Converting WebSphere Application Server configuration data into templates for more information.

  • The Cell folder contains a cell configuration template and Deployment Manager template (if applicable).
  • A folder for each node that you templatized, which contains:
    • A folder named node, which contains a node configuration template.
    • If applicable, a folder named nodeagent, which contains a node agent configuration template.
    • A folder for each server that you templatized and associated with the node. This folder contains a server template.
  • A folder for each cluster that you templatized. This folder contains a ServerTemplate folder, which in turn contains a server template used to create cluster members.

You must create a corresponding component in IBM UrbanCode Deploy for each of these high-level folders (Cell, Node, Cluster).

Creating components

In IBM UrbanCode Deploy, navigate to the Components page and then click Create Component. Enter a name for your component, and set up version source control to specify how the configuration templates are stored as component version artifacts. Click Save.

Create a component for each cell, node, and cluster.

Creating component versions and artifacts

See the appropriate topic in the product help, depending on the type of source control that you use. For example, to create component versions from a versioned file system, see Creating components from a versioned file system.

After you have created components versions, the configuration templates are displayed as component version artifacts.

Example cell component version:

Cell component


Example node component version:

Node component


Example cluster component version:

Cluster component

Creating a component process to apply configuration changes

For each component, create a process that applies configuration changes.

In IBM UrbanCode Deploy, navigate to the Components page. Select the component and then click Processes. Click Create Process. Enter a name for the process, and then click Save.

Click Edit to edit the process that you created. In the Design window, add the following steps in sequence:

  1. Add a Delete Files and Directories step to clear the working directory.
    Delete step
  2. Add a Download Artifacts step to download the component version artifacts.
    Download artifacts
  3. Add a Replace Tokens step with the following properties:
    Replace tokens
  4. For each directory in the component version artifacts, add a Run Groovy Script step. This step runs a script that combines all JSON files in the directory. This can be useful if you use snippets to add WebSphere configuration objects or if you have split a JSON file into smaller, more manageable files. The combined JSON file, which is used later when the configuration is applied, is named ibm-ucd-resources.json. For more information about snippets, see Configuration snippet overview.

Specify the directory that contains the JSON files for the working directory field. For example, for a process step to combine all JSON files in the nodeagent directory for the node component, set the working directory to:

${p:componentProcess.defaultWorkDir}/nodeagent

In the case of a cluster component, the Cluster.json file is not stored in a directory. The Cluster.json file can be merged with the servertemplate.json file, so leave the working directory to the default value.

For a cell component, add a Run Groovy Script step to merge all JSON files in the cell directory, and if applicable, a second Run Groovy Script step to merge all JSON files in the dmgr (Deployment Manager) directory.

For a node component, add a Run Groovy Script step to merge all JSON files in the node directory, a Run Groovy Script step to merge all JSON files in the nodeagent directory (if applicable), and a Run Groovy Script for each server under the node.

For a cluster component, add a single Run Groovy Script step that merges all JSON files, including the contents of the server template directory.

Each of the Run Groovy Script steps can be run concurrently and joined before continuing, as shown in the following process diagram:

Groovy process

These steps run the following Groovy code:

File file = new File("ibm-ucd-resources.json");
if (file.isDirectory()) {
    throw new Exception("Directory exists in the way");
}
if (file.isFile()) {
   System.out.println("File already created");
}
else {
    file << "[\n";     File dir = new File(".");     boolean first = true;      dir.eachFileRecurse { curfile ->
        if (curfile.getName().endsWith(".json") && !curfile.getName().equals("ibm-ucd-resources.json")) { 
            if (first) {
                first = false;
            }
            else {
                file << "," << "\n";             }             curfile.eachLine { line -> 
                file << "\n" << line;
            }
        }
    }
    file << "\n]";
}

The following screen capture is an example of the Run Groovy Script step that is used to combine the JSON files in the cell directory of a cell component. The cell directory is specified in the Working Directory field.

Working directory
  1. Add a WebSphere Configuration Apply step for each of the Run Groovy Script steps. The WebSphere Configuration Apply step applies the combined configuration data to WebSphere Application Server. The Run Groovy Script and WebSphere Configuration Apply steps cannot be run concurrently.

The working directory must be same for the WebSphere Configuration Apply step and the corresponding Run Groovy Script step. For example, if you are working with a node component and adding a step to apply node agent configuration changes, specify the following directory for the Working Directory field:

${p:componentProcess.defaultWorkDir}/nodeagent

Select Show Hidden Properties to display the hidden properties, and then specify ibm-ucd-resources.json for the WebSphere Configuration File.

Config file

The component process is now complete. The following screen capture shows an example of a cell component process to apply configuration changes:

The component process is now complete. The following screen capture shows an example of a cell component process to apply configuration changes

Creating server components

By default, server templates for servers that are not cluster members are stored with the corresponding node configuration information. You can create components that represent servers and move the server template configuration data from the node component to the new server components.

In the Server.json file for each server component version artifact, replace all instances of the server name with @websphere.server@.

In the resource tree, under the node to add the server to, locate the Servers directory. Click Show > Resource Roles, and then drag a WebSphereServer resource role object to the Servers directory. Select Add Component from the Action menu associated with the WebSphereServer resource role, and then add the server component that you created, as shown in the following screen capture.

Add component

#UrbanCodeDeploy
#WebSphereApplicationServer(WAS)
0 comments
5 views

Permalink