Workshop Exercise 5.5 - Cleaning Up after the Containerized Application

Table of Contents

Objective

To prepare for the next set of exercises, we’re going to teardown and cleanup our application deployment. This will feel much simpler than attempting to cleanup the bare metal deployment.

Step 1 - Creating a Playbook

Return to your code repo and create a playbook in the playbooks directory called cleanup-containerized-app.yml with the following contents:

---

- name: cleanup containerized application deployment
  hosts: all
  tasks:
    - name: teardown kube play
      ansible.builtin.shell:
        cmd: podman play kube --down "/home//process-control.yaml"
    - name: remove kube yaml file
      ansible.builtin.file:
        path: "/home//process-control.yaml"
        state: absent
    - name: remove images from the system
      containers.podman.podman_image:
        name: ""
        state: absent
      loop:
        - quay.io/device-edge-workshops/process-control-mqtt:1.0.0
        - quay.io/device-edge-workshops/process-control-simulate:1.0.0
        - quay.io/device-edge-workshops/process-control-control:1.0.0
        - quay.io/device-edge-workshops/process-control-ui:1.0.0
      loop_control:
        loop_var: image
    - name: close firewall port
      ansible.posix.firewalld:
        port: 1881/tcp
        zone: public
        permanent: true
        state: disabled
        immediate: true
      become: true

This playbook not only stops and removes our application deployment, but also cleans up the images from the local system.

Step 2 - Creating a Job Template

Note

Be sure to sync your project in Controller before attempting to create this job template.

In the Controller WebUI. under Resources > Templates, select Add > Add job template and enter the following information:

Parameter Value
Name Cleanup Containerized Application
Inventory Edge Systems
Project Device Edge Codebase
Execution Environment Device Edge Workshops Execution Environment
Playbook playbooks/cleanup-containerized-app.yml
Credentials
  • ✓ Device Credentials
  • Limit
  • ✓ Prompt on launch
  • Remember to click Save.

    Step 3 - Running the Job Template

    Now that the job template has been created, click the Launch button if you are still within the Cleanup Containerized Application Job Template. Otherwise, click on the rocket ship on the Templates page to launch the job template. Enter your device name when prompted on the limits page. Monitor the output for any errors or issues. However, hopefully the job executes successfully.

    As a reminder, the output of jobs can be reviewed on the Jobs tab.

    Once the playbook completes, you should no longer be able to access the application as it has been uninstalled.

    Solutions

    Our systems are now back to a known good, clean state where we can start our deployment again.

    Cleanup Bare Metal App Job Template


    Navigation

    Previous Exercise Next Exercise

    Click here to return to the Workshop Homepage