|
| 1 | +--- |
| 2 | +# Copyright (c) 2024 2025 Oracle and/or its affiliates. |
| 3 | +# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0. |
| 4 | +# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl) |
| 5 | +# See LICENSE.TXT for details. |
| 6 | + |
| 7 | +- name: Terminate instances and delete OCI resources |
| 8 | + hosts: localhost |
| 9 | + vars_files: |
| 10 | + - default_vars.yml |
| 11 | + |
| 12 | + tasks: |
| 13 | + |
| 14 | + - name: Terminate the instances |
| 15 | + oracle.oci.oci_compute_instance: |
| 16 | + id: "{{ hostvars[item]['instance_ocid'] }}" |
| 17 | + state: absent |
| 18 | + loop: "{{ groups['engine'] + groups['kvm'] }}" |
| 19 | + |
| 20 | + - name: Delete the vlan |
| 21 | + oracle.oci.oci_network_vlan: |
| 22 | + vlan_id: "{{ my_vlan_id }}" |
| 23 | + state: absent |
| 24 | + |
| 25 | + - name: Delete network_security_group |
| 26 | + oracle.oci.oci_network_security_group: |
| 27 | + network_security_group_id: "{{ my_l2_vlan_nsg_id }}" |
| 28 | + state: absent |
| 29 | + |
| 30 | + - name: Delete the subnet2 |
| 31 | + oracle.oci.oci_network_subnet: |
| 32 | + id: "{{ my_subnet2_id }}" |
| 33 | + state: absent |
| 34 | + |
| 35 | + - name: Delete the subnet1 |
| 36 | + oracle.oci.oci_network_subnet: |
| 37 | + id: "{{ my_subnet1_id }}" |
| 38 | + state: absent |
| 39 | + |
| 40 | + - name: Delete the security list |
| 41 | + oracle.oci.oci_network_security_list: |
| 42 | + id: "{{ my_security_list_id }}" |
| 43 | + state: absent |
| 44 | + |
| 45 | + - name: Delete the private route table |
| 46 | + oracle.oci.oci_network_route_table: |
| 47 | + id: "{{ my_private_rt_id }}" |
| 48 | + state: absent |
| 49 | + |
| 50 | + - name: Delete the public route table |
| 51 | + oracle.oci.oci_network_route_table: |
| 52 | + id: "{{ my_public_rt_id }}" |
| 53 | + state: absent |
| 54 | + |
| 55 | + - name: Delete the Service Gateway |
| 56 | + oracle.oci.oci_network_service_gateway: |
| 57 | + id: "{{ my_service_gateway_id }}" |
| 58 | + state: absent |
| 59 | + |
| 60 | + - name: Delete the Internet Gateway |
| 61 | + oracle.oci.oci_network_internet_gateway: |
| 62 | + id: "{{ my_internet_gateway_id }}" |
| 63 | + state: absent |
| 64 | + |
| 65 | + - name: Delete the VCN |
| 66 | + oracle.oci.oci_network_vcn: |
| 67 | + vcn_id: "{{ my_vcn_id }}" |
| 68 | + state: absent |
| 69 | + |
| 70 | + - name: Remove artifacts |
| 71 | + ansible.builtin.file: |
| 72 | + state: absent |
| 73 | + path: "{{ item }}" |
| 74 | + loop: |
| 75 | + - oci_vars.yml |
| 76 | + - buffer |
| 77 | + - hosts |
0 commit comments