create ansible playbook for WebSphere application deploy and uninstall

STEP 1. for WebSphere application deployment, we have two files: deploy.sh and deploy.yml

########deploy.sh############
/app/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -conntype none -lang jython -c "AdminApp.install('/home/vadmin/SampleWebApp.war', ['-appname', 'PlantsByWebSphere', '-contextroot', 'my_uri', '-usedefaultbindings', '-server', 'server1'])"

########deploy.yml############
- hosts: was
  tasks:
  - name: Ansible copy file to remote server
    copy:
            src: /home/vadmin/SampleWebApp.war
            dest: /home/vadmin/SampleWebApp.war
  - name: Copy and Execute the script
    script:
            /home/vadmin/deploy.sh
########## start application ##################
cat start_app.py
appManager = AdminControl.queryNames('type=ApplicationManager,process=server1,*')
AdminControl.invoke(appManager, 'startApplication', 'PlantsByWebSphere')

########## ansible debug/check commands##################
ansible-playbook deploy.yml --start-at-task="Copy and Execute the script"
ansible-playbook deploy.yml --syntax-check
ansible-playbook deploy.yml --step

STEP 2. uninstall the apps

################undeploy.sh##############
/app/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -conntype none -lang jython -c "AdminApp.uninstall('PlantsByWebSphere')"

#############undeploy.yml####################
- hosts: was
  tasks:
  - name: Copy and Execute the script
    script:
            /home/vadmin/undeploy.sh

Leave a Reply

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