How-tos

Quick tests of WebSphere apps, easily done in the cloud

Share this post:

There are several cases where it is useful to be able to stand up additional WebSphere capacity for a limited time period, without needing to worry about data center server capacity and software licenses.
Typical examples include batch type workloads, test of new code at infrequent intervals, maybe as part of an overall application modernization strategy.

What is Ansible?

Ansible is a popular open-source agentless automation engine that automates software provisioning, configuration management, and application deployment.

WebSphere Application Server in Bluemix is perfect for these type of use cases, being able to provision a dedicated WebSphere environment charged by the hour. When you don’t need the environment you can shut it down, hence saving cost.
More information in Bluemix Documentation Pages

However, as the mantra goes, if you do something more than once – automate it.

This is why we created the wascloud Ansible Module.
This module allows you to manage WebSphere Cloud Instances in similar fashion to the way you would manage AWS, OpenStack and SoftLayer VMs through the corresponding modules.

By using the dynamic inventory functions in Ansible you can create instances, configure websphere and load WebSphere applications as part of a single playbook.

Usage

The module takes the following input

region: Bluemix region, one of ng (us south), eu-gb (london), au-syd (sydney)
org: Your bluemix organisation
space: The bluemix space to provision in
apikey: Your bluemix api key

name: Name of WebSphere on Cloud instance to create or delete
state: One of
present – Creates a new instance if no instance by that name exists. If it exists the resource information for the instance is returned.
absent – Deletes an instance if it exists.
latest / reloaded – Creates an instance if no instance by that name exists, if instance already exists old instance is deleted. Can be used to ensure latest fixpacks and os patches are applied, and to re-set configurations.

type: Can be one of LibertyCollective, LibertyCore, LibertyNDServer, WASBase, WASCell or WASNDServer
size: T-Shirt size for the application server(s) as supported by WAS Broker. Currently supported: s, m, l, xl, xxl
wait: whether to wait until instance fully provisioned before continuing the playbook. If the playbook includes tasks to be performed on the newly created instance this needs to be set to true

WASCell and LibertyCollective has these additional parameters:
controller_size: T-Shirt size of the controller VM. Currently supported: s, m, l, xl, xxl
app_vms: How many application server VMs to create.

For WASBase, WASCell and WASNDServer:
software_level: Which software level of WAS to deploy. Currently available 8.5.5 and 9.0.0. Defaults to 9.0.0 if not specified.

Module return

The module returns a number of useful variables that you can capture with the ansible register method.
If the VM details of the instance is available, all the details from the WASBroker API Instance Resouce is passed into the resources list.

Importantly you will see that the wasAdminUser and the randomly generated wasAdminPassword is passed in here, so you can use it for further configuration automation

 

name description returned type sample
instance_deleted
Whether an instance was deleted during the task run
always boolean
public_ip
The public IP address for the service instance
When public_ip is set to True in playbook string
resources
List of resources in the WAS service instance. If the service instance is not ready an empty list is returned
always list [{‘machinename’: ‘string’, ‘machinestatus’: ‘string’, ‘memory’: 0, ‘osAdminPassword’: ‘string’, ‘waslink’: ‘string’, ‘wasAdminPass’: ‘string’, ‘expireTime’: ‘string’, ‘creationTime’: ‘string’, ‘wasAdminUser’: ‘string’, ‘WASaaSresourceID’: ‘string’, ‘virtuserPrivateSshKey’: ‘string’, ‘publicIpInfo’: {‘open’: True, ‘publicIp’: ‘string’, ‘ipResourceId’: ‘string’, ‘ipResourceStatus’: ‘string’}, ‘osType’: ‘string’, ‘keyStorePassword’: ‘string’, ‘ifixinfo’: ‘string’, ‘vpnConfigLink’: ‘string’, ‘disk’: 0, ‘osHostname’: ‘string’, ‘vcpu’: 0, ‘osAdminUser’: ‘string’}]

Pre-requisites

To work with the WAS Broker you must have a Bluemix API key.
Information on getting the API key from the Bluemix IAM Documentation pages
This allows you to create, delete and get information about WAS Instances

To work on the websphere instance you will need an OpenVPN connection to WebSphere region.
Information on setting up the OpenVPN connection from the Bluemix ApplicationServices Documentation pages

The module has been submitted for inclusion in Ansible 2.5, but in the meantime the code needs to be placed in one of the defined Ansible library paths, so Ansible can find it.
Generally it should suffice to place it in ./library along the playbook. More about this approach as well as other approaches on the Ansible Documentation pages

And of course, you need a working version of Ansible installed.

Example usage

There are plenty of examples in the github repository (link to follow)


---
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- ../bluemix-vars.yaml

  tasks:

  - name: create instance
wascloud_instance:
state: latest
name: "{{ was_instance_name }}"
instance_type: WASBase
size: s
region: "{{ region }}"
org: "{{ org }}"
space: "{{ space }}"
apikey: "{{ apikey }}"
wait: True
register: was_instance

- name: Add new instance to host group
add_host:
hostname: "{{ item.osHostname }}"
groupname: launched
ansible_user: "{{ item.osAdminUser }}"
ansible_ssh_pass: "{{ item.osAdminPassword }}"
ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o PreferredAuthentications=password -o PubkeyAuthentication=no"
wasadmin: "{{ item.wasAdminUser }}"
wasadminpass: "{{ item.wasAdminPass }}"
with_items: "{{ was_instance.resources }}"
- name: Wait for ssh to become available
wait_for:
host: "{{ item.osHostname }}"
port: 22
sleep: 2
timeout: 300
state: started
with_items: "{{ was_instance.resources }}"

- hosts: launched
gather_facts: True
vars_files:
- db-vars.yaml
roles:
- my_important_role
- my_important_tests

 

Now what?

If you’re looking at WebSphere Application Modernization, and you haven’t read it yet, you should head over and read Rick Osowskis blog on WebSphere on the Cloud: Application Modernization

To get your hands dirty, head over to the ansible-wascloud github repo, look at some of the examples there and try adapt one to fit your requirements.

More How-tos stories
May 6, 2019

Are You Ready for SAP S/4HANA Running on Cloud?

Our clients tell us SAP applications are central to their success and strategy for cloud, with a deadline to refresh the business processes and move to SAP S/4HANA by 2025. Now is the time to assess, plan and execute the journey to cloud and SAP S/4HANA

Continue reading

May 2, 2019

Seamless Integration: Istio and External Services

By defining our own MCP server, we allow users to move to the Istio service mesh without any code and deployment model changes. This means we can easily use Istio to control, observe, connect, and secure services running outside Kubernetes clusters.

Continue reading

May 1, 2019

What’s Included in the IBM Cloud Developer Tools Version 2.2.0

I’m pleased to announce the latest version of IBM Cloud Developer Tools CLI, which contains some exciting new features.

Continue reading