Commit 18fb164f authored by Sergio Gimenez's avatar Sergio Gimenez
Browse files

Quick undeployment for the dual oop deployment

parent 78afdcdb
Loading
Loading
Loading
Loading
+78 −0
Original line number Diff line number Diff line
---
# Playbook: Quick Undeploy Two Full OOPs Scenario
# Description: Quickly removes two complete Operator Platform environments by deleting Kind clusters
# Usage: ansible-playbook playbooks/scenarios/quick_undeploy_full_oops.yml

- name: Undeploy First OP (OP1)
  hosts: op1_nodes
  gather_facts: true
  tags: [op1]
  
  tasks:
    - name: Load group variables
      ansible.builtin.include_vars:
        file: "{{ playbook_dir }}/../../group_vars/all.yml"

    - name: Set OP1 cluster name
      ansible.builtin.set_fact:
        kind_cluster_name: "op1"

    - name: Delete OP1 Kind Cluster
      ansible.builtin.command:
        cmd: kind delete cluster --name {{ kind_cluster_name }}
      register: delete_op1_result
      changed_when: delete_op1_result.rc == 0
      failed_when: false

    - name: Display OP1 deletion result
      ansible.builtin.debug:
        msg: "OP1 cluster deletion {{ 'successful' if delete_op1_result.rc == 0 else 'failed or cluster not found' }}"

    - name: Clean up OP1 kubeconfig directory
      ansible.builtin.file:
        path: "{{ op_automation_base }}/automation/op1"
        state: absent
      when: deployment_mode is not defined or deployment_mode != 'remote'

    - name: Clean up OP1 kubeconfig directory (remote)
      ansible.builtin.file:
        path: "/home/{{ ansible_user }}/kind-cluster-config"
        state: absent
      when: deployment_mode is defined and deployment_mode == 'remote'

- name: Undeploy Second OP (OP2)
  hosts: op2_nodes
  gather_facts: true
  tags: [op2]

  tasks:
    - name: Load group variables
      ansible.builtin.include_vars:
        file: "{{ playbook_dir }}/../../group_vars/all.yml"

    - name: Set OP2 cluster name
      ansible.builtin.set_fact:
        kind_cluster_name: "op2"

    - name: Delete OP2 Kind Cluster
      ansible.builtin.command:
        cmd: kind delete cluster --name {{ kind_cluster_name }}
      register: delete_op2_result
      changed_when: delete_op2_result.rc == 0
      failed_when: false

    - name: Display OP2 deletion result
      ansible.builtin.debug:
        msg: "OP2 cluster deletion {{ 'successful' if delete_op2_result.rc == 0 else 'failed or cluster not found' }}"

    - name: Clean up OP2 kubeconfig directory
      ansible.builtin.file:
        path: "{{ op_automation_base }}/automation/op2"
        state: absent
      when: deployment_mode is not defined or deployment_mode != 'remote'

    - name: Clean up OP2 kubeconfig directory (remote)
      ansible.builtin.file:
        path: "/home/{{ ansible_user }}/kind-cluster-config"
        state: absent
      when: deployment_mode is defined and deployment_mode == 'remote'