-
Notifications
You must be signed in to change notification settings - Fork 500
/
destroy_env_osp.yml
75 lines (71 loc) · 2.49 KB
/
destroy_env_osp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
# Call Remove Workloads for workloads that need to clean up "other" infrastructure.
# Those removal playbooks need to be able to be run on the provisioning host (aka not a Bastion)
- name: Remove workloads
hosts: localhost
connection: local
gather_facts: false
run_once: true
become: false
tasks:
- name: Remove ocp workloads
when: remove_workloads | default("") | length > 0
block:
- name: Invoke roles to remove ocp workloads
ansible.builtin.include_role:
name: "{{ workload_loop_var }}"
vars:
ocp_username: "system:admin"
ACTION: "remove"
loop: "{{ remove_workloads }}"
loop_control:
loop_var: workload_loop_var
- name: Delete environment on OpenStack
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- name: Remove DNS entry for OpenShift API and ingress
community.general.nsupdate:
server: >-
{{ osp_cluster_dns_server
| ipaddr
| ternary(osp_cluster_dns_server, lookup('dig', osp_cluster_dns_server))
}}
zone: "{{ osp_cluster_dns_zone }}"
record: "{{ item }}.cluster-{{ guid }}"
type: A
key_name: "{{ ddns_key_name }}"
key_algorithm: "{{ ddns_key_algorithm | d('hmac-md5') }}"
key_secret: "{{ ddns_key_secret }}"
state: absent
loop:
- "api"
- "*.apps"
when:
- openshift_fip_provision
- use_dynamic_dns
# OpenShift IPI Install creates an RH CoreOS Image in OpenStack (qcow2 format)
# Delete the image if it exists
# Image is named something like `cluster-wkrhtr-77jgv-rhcos` where `cluster-wkrhtr-77jgv` is
# the name of the cluster
# Only do this step if no image was set for the installation (and therefore the installer downloaded an image)
- name: Delete CoreOS Image
when: rhcos_image_name | default("") | length == 0
block:
- name: Get Cluster Name
kubernetes.core.k8s_info:
kubeconfig: "/home/cloud-user/cluster-{{ guid }}/auth/kubeconfig"
api_version: config.openshift.io/v1
kind: Infrastructure
name: cluster
register: r_infrastructure
ignore_errors: true
- name: Delete CoreOS Image if it exists
when: r_infrastructure is not failed
openstack.cloud.image:
state: absent
name: "{{ r_infrastructure.resources[0].status.infrastructureName }}-rhcos"
- name: Import default cloud provider destroy playbook
ansible.builtin.import_playbook: "../../cloud_providers/{{ cloud_provider }}_destroy_env.yml"