---
- 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
Žádné komentáře:
Okomentovat