From a858b038577590da649503c6d7a7488e9a254805 Mon Sep 17 00:00:00 2001 From: Marco Braga Date: Wed, 8 Mar 2023 10:56:29 -0300 Subject: [PATCH] feat/destroy: add OCI destroy resources --- playbooks/destroy_cluster.yaml | 22 ++++++++++++++++----- playbooks/vars/oci/profiles/ha/dns.yaml | 3 +++ playbooks/vars/oci/profiles/ha/network.yaml | 1 - roles/bootstrap/tasks/oci.yaml | 8 ++++---- roles/clients/tasks/main.yaml | 6 ++++-- roles/cloud_compute | 2 +- roles/cloud_load_balancer | 2 +- 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/playbooks/destroy_cluster.yaml b/playbooks/destroy_cluster.yaml index 4f87346..10dc9bd 100644 --- a/playbooks/destroy_cluster.yaml +++ b/playbooks/destroy_cluster.yaml @@ -8,6 +8,7 @@ - name: OKD Installer | Destroy | Timer start ansible.builtin.set_fact: okdi_del_timer_start: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}" + tags: all # - ansible.builtin.import_playbook: var_check_required.yaml @@ -31,43 +32,52 @@ - name: okd-installer | Destroy | Network | Loading Topology Names ansible.builtin.include_vars: file: "{{ profile_path }}/network.yaml" + tags: all # Load Balancers - name: okd-installer | Destroy | LB | Init list ansible.builtin.set_fact: load_balancers_all: [] + tags: all - name: okd-installer | Destroy | Load Resource Names ansible.builtin.include_vars: file: "{{ profile_path }}/destroy_resources.yaml" + tags: all - - name: okd-installer | Destroy | LB | Load Router Names + - name: okd-installer | Destroy | LB | Load LB Names ansible.builtin.include_vars: file: "{{ profile_path }}/loadbalancer-router-default.yaml" + tags: all - - name: okd-installer | Destroy | LB | Merge list + - name: okd-installer | Destroy | LB | Merge list w/ router ansible.builtin.set_fact: - load_balancers_all: "{{ load_balancers_all + cloud_loadbalancers }}" + load_balancers_all: "{{ (load_balancers_all | d([])) + (cloud_loadbalancers | d([])) }}" + tags: all - name: okd-installer | Destroy | LB | Load API Names ansible.builtin.include_vars: file: "{{ profile_path }}/loadbalancer.yaml" + tags: all - name: okd-installer | Destroy | LB | Merge list ansible.builtin.set_fact: - load_balancers_all: "{{ load_balancers_all + cloud_loadbalancers }}" + load_balancers_all: "{{ load_balancers_all + (cloud_loadbalancers | d([])) }}" + tags: all - name: okd-installer | Destroy | LB | Consolidate ansible.builtin.set_fact: cloud_loadbalancers: "{{ load_balancers_all }}" + tags: all - name: okd-installer | Destroy | LB | Show number of resources ansible.builtin.debug: msg: "Found {{ cloud_loadbalancers | length }} Load Balancers on the Configuration" + tags: all roles: - role: destroy - + tags: all - name: okd-installer | Destroy | Finish hosts: '{{ target|default("localhost") }}' @@ -77,9 +87,11 @@ - name: okd-installer | Destroy | Finish | Timer end ansible.builtin.set_fact: okdi_del_timer_end: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}" + tags: all - name: okd-installer | Destroy | Finish | Show timers ansible.builtin.debug: msg: - "start=[{{ okdi_del_timer_start | d('') }}] end=[{{ okdi_del_timer_end }}]" - "total=[{{ ((okdi_del_timer_end | to_datetime) - (okdi_del_timer_start | to_datetime)) }}]" + tags: all diff --git a/playbooks/vars/oci/profiles/ha/dns.yaml b/playbooks/vars/oci/profiles/ha/dns.yaml index a117913..0a9c737 100644 --- a/playbooks/vars/oci/profiles/ha/dns.yaml +++ b/playbooks/vars/oci/profiles/ha/dns.yaml @@ -11,6 +11,9 @@ cloud_dns_zones: # zone_type: PRIMARY compartment_id: "{{ oci_compartment_id_dns | d(oci_compartment_id) }}" + # OCI is using subnet's zone. + # TODO: Need to check if will not conflict with custom private zone. + # Currently the cluster is resolving the DNS using the public zone. # private # - name: "{{ cluster_state.dns.cluster_domain }}" # provider: oci diff --git a/playbooks/vars/oci/profiles/ha/network.yaml b/playbooks/vars/oci/profiles/ha/network.yaml index dd551ed..54869c6 100644 --- a/playbooks/vars/oci/profiles/ha/network.yaml +++ b/playbooks/vars/oci/profiles/ha/network.yaml @@ -86,7 +86,6 @@ cloud_networks: # network_entity_type: nat-gateway # network_entity_name: "{{ cluster_state.infra_id }}-natgw" - # create permissive security Lists to force to use NSGs # https://docs.oracle.com/en-us/iaas/tools/oci-ansible-collection/4.12.0/collections/oracle/oci/oci_network_security_list_module.html#ansible-collections-oracle-oci-oci-network-security-list-module security_lists: diff --git a/roles/bootstrap/tasks/oci.yaml b/roles/bootstrap/tasks/oci.yaml index afbd2b5..13de844 100644 --- a/roles/bootstrap/tasks/oci.yaml +++ b/roles/bootstrap/tasks/oci.yaml @@ -2,14 +2,14 @@ # https://docs.oracle.com/en-us/iaas/tools/oci-ansible-collection/4.12.0/collections/oracle/oci/oci_object_storage_object_module.html#ansible-collections-oracle-oci-oci-object-storage-object-module # https://docs.oracle.com/en-us/iaas/tools/oci-ansible-collection/4.12.0/collections/oracle/oci/oci_object_storage_object_module.html#ansible-collections-oracle-oci-oci-object-storage-object-module -- name: Get a specific namespace +- name: OCI | Get the namespace oracle.oci.oci_object_storage_namespace_facts: compartment_id: "{{ oci_compartment_id }}" register: _objns - debug: var=_objns -- name: Create bucket +- name: OCI | Create bucket oracle.oci.oci_object_storage_bucket: compartment_id: "{{ oci_compartment_id }}" name: "{{ bootstrap_bucket }}" @@ -17,7 +17,7 @@ state: present # TODO: Make it indepotent -- name: Upload bootstrap.ign +- name: OCI | Upload bootstrap.ign oracle.oci.oci_object_storage_object: namespace_name: "{{ _objns.namespace }}" bucket_name: "{{ bootstrap_bucket }}" @@ -26,7 +26,7 @@ force: false register: _upload -- name: OCI | Create expieration timestamp +- name: OCI | Create expiration timestamp ansible.builtin.command: "date +'%Y-%m-%dT%H:%M:%S%z' -d '+1 hour'" register: _cmd changed_when: false diff --git a/roles/clients/tasks/main.yaml b/roles/clients/tasks/main.yaml index 587a0d9..846ff57 100644 --- a/roles/clients/tasks/main.yaml +++ b/roles/clients/tasks/main.yaml @@ -34,7 +34,7 @@ - name: openshift-install | Download msg ansible.builtin.debug: - msg: "Donwloading tools [{{ release_image_version_arch | d(local_version) }}] using secret [{{ config_pull_secret_file }}]" + msg: "Downloading tools [{{ release_image_version_arch | d(local_version) }}] using secret [{{ config_pull_secret_file }}]" when: not(check_tar_inst.stat.exists) - name: openshift-install | Check vars @@ -142,7 +142,9 @@ - name: Show clients path ansible.builtin.debug: - msg: "binary=[{{ item.src }}] link=[{{ item.link }}]" + msg: + - "binary=[{{ collection_bin_dir }}/{{ item.src }}]" + - "link=[{{ collection_bin_dir }}/{{ item.link }}]" with_items: - src: "{{ bin_installer }}" link: openshift-install diff --git a/roles/cloud_compute b/roles/cloud_compute index cd201c8..1d70aaa 160000 --- a/roles/cloud_compute +++ b/roles/cloud_compute @@ -1 +1 @@ -Subproject commit cd201c8be746dfee6a4fb617bb874695fafb7c83 +Subproject commit 1d70aaad2a2b4963a6e91cf317382126473cb221 diff --git a/roles/cloud_load_balancer b/roles/cloud_load_balancer index f5ec082..ea528dc 160000 --- a/roles/cloud_load_balancer +++ b/roles/cloud_load_balancer @@ -1 +1 @@ -Subproject commit f5ec082e5bfa14422f11224c06d8bc3eb02a64a6 +Subproject commit ea528dcd54c2693fac828394d3be789d5d54830f