ansible playbook checkIfAppExists then undeploy/deploy in Azure pipeline

we can use this playbook.yml file to checkIfAppExists:

---
- hosts: all
  become: wasadmin
  tasks:
    - name: Register a variable
      ansible.builtin.shell: /app/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -conntype none -lang jython -c 'AdminApplication.checkIfAppExists("PlantsByWebSphere")'
      register: checkIfAppExists_out
    - debug: var=checkIfAppExists_out.stdout_lines
    - name: undeploy
      ansible.builtin.command: /app/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -conntype none -lang jython -c "AdminApp.uninstall('PlantsByWebSphere')"
      when: not "false" in checkIfAppExists_out.stdout
    - name: deploy war file
      ansible.builtin.command: /app/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -conntype none -lang jython -c "AdminApp.install('/home/vadmin/jsat-API-{{env_name}}-1.0.0.war', ['-appname', 'PlantsByWebSphere', '-usedefaultbindings', '-server', 'server1'])"
    - name: start the application
      ansible.builtin.command: /app/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -lang jython -c "AdminApplication.startApplicationOnSingleServer('PlantsByWebSphere', 'AppNode01', 'server1')"

Here is the output from pipeline:

2021-12-15T15:14:52.3811853Z PLAY [all] *********************************************************************
2021-12-15T15:14:52.3903924Z 
2021-12-15T15:14:52.3904885Z TASK [Gathering Facts] *********************************************************
2021-12-15T15:14:55.6895107Z ok: [10.200.14.87]
2021-12-15T15:14:55.7094046Z 
2021-12-15T15:14:55.7102411Z TASK [Register a variable] *****************************************************
2021-12-15T15:15:00.6996473Z changed: [10.200.14.87]
2021-12-15T15:15:00.7187784Z 
2021-12-15T15:15:00.7189161Z TASK [debug] *******************************************************************
2021-12-15T15:15:00.7670493Z ok: [10.200.14.87] => {
2021-12-15T15:15:00.7671874Z     "checkIfAppExists_out.stdout_lines": [
2021-12-15T15:15:00.7672744Z         "WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.", 
2021-12-15T15:15:00.7674211Z         "---------------------------------------------------------------", 
2021-12-15T15:15:00.7674861Z         " AdminApplication:       Check if application exists", 
2021-12-15T15:15:00.7675503Z         " Application Name:       PlantsByWebSphere", 
2021-12-15T15:15:00.7676093Z         " Usage: AdminApplication.checkIfAppExists(\"PlantsByWebSphere\")", 
2021-12-15T15:15:00.7676828Z         " Return: Checks whether the application exists. If the application exists, a true value is returned.", 
2021-12-15T15:15:00.7677784Z         "---------------------------------------------------------------", 
2021-12-15T15:15:00.7678312Z         " ", 
2021-12-15T15:15:00.7679286Z         " ", 
2021-12-15T15:15:00.7679870Z         "'false'"
2021-12-15T15:15:00.7680488Z     ]
2021-12-15T15:15:00.7681033Z }
2021-12-15T15:15:00.7849801Z 
2021-12-15T15:15:00.7851020Z TASK [undeploy] ****************************************************************
2021-12-15T15:15:00.8276416Z skipping: [10.200.14.87]
2021-12-15T15:15:00.8464468Z 
2021-12-15T15:15:00.8467003Z TASK [deploy war file] *********************************************************
2021-12-15T15:15:29.0518902Z changed: [10.200.14.87]
2021-12-15T15:15:29.0530467Z 
2021-12-15T15:15:29.0531564Z PLAY RECAP *********************************************************************
2021-12-15T15:15:29.0532228Z 10.200.14.87               : ok=4    changed=2    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   

Leave a Reply

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