forked from validatedpatterns/agof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teardown.yml
79 lines (72 loc) · 2.07 KB
/
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
---
- name: Perform Checks to make sure this Playbook will complete successfully
hosts: localhost
connection: local
become: false
gather_facts: true
vars_files:
- "../../vars/main.yml"
- "vars/aws_vars.yml"
- "~/agof_vault.yml"
tasks:
- name: collection final check
block:
- name: run AWS check setup if using AWS
include_role:
name: roles/aws_check_setup
rescue:
- name: Error with setup
fail:
msg: The provisioner has failed during initial check_setup, please scroll up to see exact error. Open an issue on https://github.com/validatedpatterns/agof/issues
- name: "Get info on the elements built"
hosts: localhost
connection: local
become: false
gather_facts: false
vars_files:
- "~/agof_vault.yml"
- "vars/aws_vars.yml"
tasks:
- name: "Retrieve info on built infrastructure"
ansible.builtin.include_role:
name: roles/manage_ec2_infra
- name: "Get info on VMs and Remove DNS info"
ansible.builtin.include_role:
name: roles/manage_ec2_instances
vars:
teardown: true
- name: "Remember instances for later"
ansible.builtin.set_fact:
built_instances: '{{ ec2_instances_built }}'
- name: Destroy instances in AWS
hosts: localhost
connection: local
become: false
gather_facts: false
vars_files:
- "~/agof_vault.yml"
- "vars/aws_vars.yml"
vars:
ec2_wait: false
teardown: true
s3_state: absent
state: absent
debug_teardown: false
tasks:
- name: "Retrieve info on built infrastructure"
ansible.builtin.include_role:
name: roles/manage_ec2_infra
- name: Remove route53 dns entries
become: false
amazon.aws.route53:
state: absent
zone: "{{ pattern_dns_zone }}"
record: "{{ item.tags.avpfqdn }}"
type: A
wait: true
when: manage_public_dns
loop: "{{ built_instances }}"
- name: Remove pattern local files
file:
dest: "{{ pattern_state_rootdir }}/{{ ec2_name_prefix }}"
state: absent