forked from aerospike-community/aerospike-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws-teardown.yml
82 lines (70 loc) · 1.95 KB
/
aws-teardown.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
76
77
78
79
80
81
---
- name: "Teardown the generated aerospike cluster environment"
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Import AWS constants
include_vars:
dir: vars
- name: Get VPC ID
ec2_vpc_net:
region: "{{ aws_region }}"
name: "{{ cluster_tag }}"
cidr_block: "{{ vpc_cidr }}"
register: vpc
- name: Stop instances
ec2_instance:
state: absent
region : "{{ aws_region }}"
filters:
"tag:uber-group": "{{ cluster_identifier }}"
- name: Remove Security Group
ec2_group:
state: absent
region : "{{ aws_region }}"
name: "{{ cluster_tag }} security group"
- name: Remove Internet Gateway
ec2_vpc_igw:
state: absent
region : "{{ aws_region }}"
vpc_id: "{{ vpc.vpc.id }}"
- name: Remove Route Table
ec2_vpc_route_table:
state: absent
region: "{{ aws_region }}"
vpc_id: "{{ vpc.vpc.id }}"
tags:
group: "{{ cluster_tag }}"
- name: Get subnet info
ec2_vpc_subnet_info:
region: "{{ aws_region }}"
filters:
vpc-id: "{{ vpc.vpc.id }}"
register: subnet_info
- name: Remove Subnets
ec2_vpc_subnet:
state: absent
region: "{{ aws_region }}"
vpc_id: "{{ vpc.vpc.id }}"
cidr: "{{ item.cidr_block }}"
with_items: "{{ subnet_info.subnets|list }}"
- name: Remove VPC
ec2_vpc_net:
state: absent
region: "{{ aws_region }}"
name: "{{ cluster_tag }}"
cidr_block: "{{ vpc_cidr }}"
- name: Remove Key
ec2_key:
state: absent
region: "{{ aws_region }}"
name: "{{ cluster_tag }}"
- name : "Remove key file {{ ansible_ssh_private_key_file }}"
file:
path: "{{ ansible_ssh_private_key_file }}"
state: absent
- name : "Remove generated scripts directory"
file:
path: "{{ scripts_directory_name }}"
state: absent