sobota 14. května 2022

Example of Ansible playbook to start an application in WebSphere Application Server

 ---

- name: Test was start app

  hosts: fedora_was


  vars:

   WAS_HOME: /opt/IBM/WebSphere/AppServer

   PROFILE_NAME: AppSrv01

   WASADMIN_USERNAME: wasadmin

   WASADMIN_PASSWORD: web1sphere

   APPLICATION_NAME: DefaultApplication

   


  tasks:

  

   - name: Create script file check_app_state.py

     copy:

      dest: /tmp/check_app_state.py

      content: |

        objectName = AdminControl.completeObjectName('type=Application,name=' + '{{ APPLICATION_NAME }}' + ',*'); print ('Started','Stopped')[objectName == '']

       

       

   - name: Check app state

     ansible.builtin.shell: "{{ WAS_HOME }}/bin/wsadmin.sh -lang jython -profileName {{ PROFILE_NAME }} -user {{ WASADMIN_USERNAME }} -password {{ WASADMIN_PASSWORD }} -f /tmp/check_app_state.py | sed '1d'"

     register: command_output

   - debug: msg={{ command_output.stdout }} 

 

 

   - name: Create script file start_app.py

     copy:

      dest: /tmp/start_app.py

      content: |

        appManager = AdminControl.queryNames('type=ApplicationManager,*');

        AdminControl.invoke(appManager, 'startApplication', '{{ APPLICATION_NAME }}')

   

       

   - name: Start the application

     ansible.builtin.command: "{{ WAS_HOME }}/bin/wsadmin.sh -lang jython -profileName {{ PROFILE_NAME }} -user {{ WASADMIN_USERNAME }} -password {{ WASADMIN_PASSWORD }} -f /tmp/start_app.py"

     register: start_command_output     

     when: command_output.stdout == "Stopped"

   - debug: msg={{ start_command_output.stdout }}

     when: start_command_output.stdout is defined

pátek 29. dubna 2022

How get information about the mbeans in WebSpphere Application Server runtime

 The WebSphere Application Server runs lot of mbeans. The Java Management Beans that monitor and control the application server runtime. From the fundamental components to the application and their building blocks. The structure of mbeans is very flexible and depends on configuration and topology of application servers and running applications inside.

The simple command that prints the list of all mbeans running in the examined WebSphere Application Server cell:

print AdminControl.queryNames('*');

Example of output:

WebSphere:name=ClusterMgr,process=dmgr,platform=common,node=Dmgr01Node,version=9.0.5.1,type=ClusterMgr,mbeanIdentifier=ClusterMgr,cell=Dmgr01Cell,spec=1.0

WebSphere:name=CommandAssistance,process=dmgr,platform=dynamicproxy,node=Dmgr01Node,version=9.0.5.1,type=CommandAssistance,mbeanIdentifier=CommandAssistance,cell=Dmgr01Cell,spec=1.0

WebSphere:name=ConfigService,process=dmgr,platform=proxy,node=Dmgr01Node,version=9.0.5.1,type=ConfigService,mbeanIdentifier=ConfigService,cell=Dmgr01Cell,spec=1.0

WebSphere:name=Custom01Node.server1-TESTBUS,process=server1,platform=dynamicproxy,node=Custom01Node,version=9.0.5.1,type=SIBMessagingEngine,mbeanIdentifier=cells/Dmgr01Cell/nodes/Custom01Node/servers/server1/sib-engines.xml#SIBMessagingEngine_1628767824612,cell=Dmgr01Cell,spec=1.0

.

.

.

The following command allows you to get list of attributes, operations and notifications of each MBean entry from previous list:

print Help.all('WebSphere:name=TraceService,process=server1,platform=proxy,node=Custom01Node,version=9.0.5.1,type=TraceService,mbeanIdentifier=cells/Dmgr01Cell/nodes/Custom01Node/servers/server1/server.xml#TraceService_1618218117128,cell=Dmgr01Cell,spec=1.0');

Example output:

Name: WebSphere:name=TraceService,process=server1,platform=proxy,node=Custom01Node,version=9.0.5.1,type=TraceService,mbeanIdentifier=cells/Dmgr01Cell/nodes/Custom01Node/servers/server1/server.xml#TraceService_1618218117128,cell=Dmgr01Cell,spec=1.0

        Description: Management interface for the live TraceService function running in a server.

        Class name: javax.management.modelmbean.RequiredModelMBean


Attribute                       Type                            Access

ringBufferSize                  int                             RW

traceSpecification              java.lang.String                RW

effectiveTraceSpecification     java.lang.String                RO

traceFileName                   java.lang.String                RO

traceRuntimeConfig              java.lang.String                RO

rawTraceFilterEnabled           boolean                         RW


Operation

int getRingBufferSize()

void setRingBufferSize(int)

java.lang.String getTraceSpecification()

void setTraceState(java.lang.String)

java.lang.String getEffectiveTraceSpecification()

java.lang.String getTraceFileName()

java.lang.String getTraceRuntimeConfig()

boolean isRawTraceFilterEnabled()

void setRawTraceFilterEnabled(boolean)

void appendTraceString(java.lang.String)

void dumpRingBuffer(java.lang.String)

void clearRingBuffer()

[Ljava.lang.String; listAllRegisteredComponents()

[Ljava.lang.String; listAllRegisteredGroups()

java.util.HashMap listComponentsInGroup([Ljava.lang.String;)

[Ljava.lang.String; listComponentsInGroup(java.lang.String)

[Lcom.ibm.websphere.ras.TraceElementState; getTracedComponents()

[Lcom.ibm.websphere.ras.TraceElementState; getTracedGroups()

java.lang.String getTraceSpecification(java.lang.String)

void processDumpString(java.lang.String)

void checkTraceString(java.lang.String)

void setTraceOutputToFile(java.lang.String, int, int, java.lang.String)

void setTraceOutputToRingBuffer(int, java.lang.String)

java.lang.String rolloverLogFileImmediate(java.lang.String, java.lang.String)

java.lang.String setTraceSpecification(java.lang.String)



Notifications

jmx.attribute.changed


Constructors


The combination of this simple commands allows you to explore every MBean in the running WebSphere Application Server runtime and use the attributes, operations to obtain the current state or control every part of the application server ecosystem.



How to resolve WebSphere variables in the wsadmin scripts (expandVariable operation of the AdminOperations mbean)

The WebSphere Application Server configuration values can contain references to WebSphere variables. 

This is an important and useful concept that allows substitute values using variables in the configuration. It has some drawback on the other side when you write the jython administrative script. The wsadmin commands does not resolve the variables to values automatically.  

For example if you want to obtain the full path to log file you will use following jython commands in wsadmin script:


server = AdminConfig.getid('/Node:AppSrv01Node01/Server:server1');

systemOutLog = AdminConfig.showAttribute(server, 'outputStreamRedirect');

logFileName=AdminConfig.showAttribute(systemOutLog,'fileName');

print logFileName;

The ouptut is:

${SERVER_LOG_ROOT}/SystemOut.log


Not much useful, because you don't know what the value of the SERVER_LOG_ROOT variable.


The following example shows how to resolve the variable values in the Jython code. Each WebSphere Application Server has the mbean AdminOperations in runtime. The AdminOperations has the expandVariable operation that resolves WebSphere variables in the string.


# find the AdminOperations mbean in server runtime 

AdminOperations = AdminControl.completeObjectName('WebSphere:*,node=AppSrv01Node01,process=server1,type=AdminOperations');

# call the operation expandVariable on that bean

print AdminControl.invoke(AdminOperations,'expandVariable','${SERVER_LOG_ROOT}/SystemOut.log');

The output is:

C:\IBM\WebSphere\AppServer\profiles\AppSrv01/logs/server1/SystemOut.log



 

neděle 15. dubna 2018

Kompozitní repository pro WAS9

WebSphere Application Server, Network Deployment composite repository
https://www-147.ibm.com/software/repositorymanager/com.ibm.websphere.BASE.V90


WebSphere Application Server, Network Deployment composite repository
https://www-147.ibm.com/software/repositorymanager/com.ibm.websphere.ND.V90