-
Notifications
You must be signed in to change notification settings - Fork 5
/
destroy_cluster.yml
66 lines (54 loc) · 1.74 KB
/
destroy_cluster.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
- hosts: localhost
gather_facts: false
vars_files:
- ./vars/main.yml
tasks:
- name: Find all cluster instances
openstack.cloud.server_info:
server: "{{ cluster_name }}*"
register: cluster_instances
- name: Delete all cluster instances
openstack.cloud.server:
name: "{{ item.name }}"
state: absent
delete_fip: true
loop: "{{ cluster_instances.openstack_servers }}"
- name: Delete cluster subnet router
openstack.cloud.router:
name: "{{ cluster_network_router }}"
state: absent
- name: Delete cluster subnet
openstack.cloud.subnet:
name: "{{ cluster_network_name }}"
state: absent
- name: Delete cluster network
openstack.cloud.network:
name: "{{ cluster_network_name }}"
state: absent
- name: Delete cluster head node boot volume
openstack.cloud.volume:
name: "{{ head_node_volume }}"
state: absent
- name: Delete all cluster volumes
openstack.cloud.volume:
name: "{{ item.name }}"
state: absent
loop: "{{ cluster_instances.openstack_servers }}"
- name: Delete compute node image volume
openstack.cloud.volume:
name: "{{ compute_node_image }}"
state: absent
- name: Delete cluster security group
openstack.cloud.security_group:
name: "{{ cluster_security_group }}"
state: absent
- name: Delete cluster ssh keypair
os_keypair:
name: "{{ keypair_name }}"
state: absent
- name: Delete compute node image
openstack.cloud.image:
name: "{{ compute_node_image}}"
state: absent
- debug:
msg: "Cleaned up {{ cluster_name }} cloud resources."