-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
delete.yml
63 lines (56 loc) · 1.98 KB
/
delete.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
---
- hosts: localhost
gather_facts: false
vars_files:
- vars/main.yml
tasks:
- name: Get Route53 hosted zones (if configured).
route53_zone:
zone: '{{ wordpress_route53_zone }}'
register: hosted_zone
when: wordpress_route53_zone != ''
- name: Get Route53 record (if configured).
route53_info:
profile: "{{ aws_profile }}"
type: A
query: record_sets
start_record_name: '{{ wordpress_route53_domain }}'
hosted_zone_id: '{{ hosted_zone.zone_id }}'
hosted_zone_method: list_by_name
register: route53_record
when: wordpress_route53_domain != ''
- name: Delete Route53 record (if found).
route53:
profile: "{{ aws_profile }}"
zone: '{{ wordpress_route53_zone }}'
record: '{{ wordpress_route53_domain }}.'
state: absent
type: A
ttl: 300
value: "{{ route53_record['ResourceRecordSets'][0]['AliasTarget']['DNSName'] }}"
alias: true
alias_hosted_zone_id: "{{ route53_record['ResourceRecordSets'][0]['AliasTarget']['HostedZoneId'] }}"
when:
- route53_record['ResourceRecordSets'][0]['AliasTarget'] is defined
- wordpress_route53_domain in route53_record['ResourceRecordSets'][0]['Name']
- name: Delete Wordpress resources.
k8s:
definition: '{{ item }}'
kubeconfig: '{{ k8s_kubeconfig }}'
state: absent
loop:
- "{{ lookup('template', 'wordpress/mysql.yml') | from_yaml_all | list }}"
- "{{ lookup('template', 'wordpress/wordpress.yml') | from_yaml_all | list }}"
- name: Pause execution for two minutes for resource deletion.
pause:
minutes: 2
- name: Delete CloudFormation stacks.
cloudformation:
stack_name: "{{ item }}"
state: absent
region: "{{ aws_region }}"
profile: "{{ aws_profile }}"
with_items:
- eks-example-nodegroup
- eks-example-cluster
- eks-example-vpc