Skip to content

Commit

Permalink
feat/destroy: add OCI destroy resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mtulio committed Mar 8, 2023
1 parent 2994985 commit a858b03
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
22 changes: 17 additions & 5 deletions playbooks/destroy_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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") }}'
Expand All @@ -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
3 changes: 3 additions & 0 deletions playbooks/vars/oci/profiles/ha/dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion playbooks/vars/oci/profiles/ha/network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions roles/bootstrap/tasks/oci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
# 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 }}"
namespace_name: "{{ _objns.namespace }}"
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 }}"
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions roles/clients/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion roles/cloud_compute
2 changes: 1 addition & 1 deletion roles/cloud_load_balancer

0 comments on commit a858b03

Please sign in to comment.