forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdestroy_env_osp.yml
54 lines (51 loc) · 1.79 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
---
- import_playbook: ../../setup_runtime.yml
- name: Delete environment on OpenStack
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- name: Remove DNS entry for OpenShift API and ingress
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
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
os_image:
state: absent
name: "{{ r_infrastructure.resources[0].status.infrastructureName }}-rhcos"
- name: Import default cloud provider destroy playbook
import_playbook: "../../cloud_providers/{{ cloud_provider }}_destroy_env.yml"