commit | author | age
|
bf4161
|
1 |
--- |
JR |
2 |
# Implement your Workload removal tasks here |
b85c91
|
3 |
- name: Install AWS python prerequisites |
RM |
4 |
become: True |
|
5 |
pip: |
|
6 |
state: present |
|
7 |
name: |
|
8 |
- boto |
|
9 |
- botocore |
|
10 |
- boto3 |
bf4161
|
11 |
|
JR |
12 |
# Find IP of bastion |
|
13 |
- name: Gather VPC facts |
|
14 |
ec2_vpc_net_facts: |
|
15 |
filters: |
|
16 |
tag:Name: "{{ aws_vpc_name }}" |
|
17 |
region: "{{ aws_region_final | default(aws_region) }}" |
|
18 |
register: vpc |
|
19 |
|
|
20 |
- name: Get instance facts |
|
21 |
ec2_instance_facts: |
|
22 |
filters: |
|
23 |
# FIXME - find a better way to discover the bastion name |
|
24 |
"tag:Name": "{{ instances[0].name }}" |
|
25 |
region: "{{ aws_region_final | default(aws_region) }}" |
|
26 |
register: instancesr |
|
27 |
failed_when: instancesr|length == 0 |
|
28 |
|
|
29 |
- name: Get non-terminated instance |
|
30 |
set_fact: |
|
31 |
ec2instance: "{{ item }}" |
|
32 |
with_items: |
|
33 |
- "{{ instancesr.instances }}" |
|
34 |
when: not item.state.name == 'terminated' |
|
35 |
failed_when: ec2instance is undefined |
|
36 |
|
|
37 |
# Remove external DNS of IdM in OpenShift cluster private zone |
|
38 |
- name: Get cluster metadata |
|
39 |
slurp: |
|
40 |
path: "{{ cluster_name }}/metadata.json" |
|
41 |
register: metadata |
|
42 |
|
|
43 |
- name: Get cluster infrastructure ID |
|
44 |
set_fact: |
|
45 |
cluster_vpc_name: "{{ metadata.content | b64decode | from_json | json_query('infraID')}}-vpc" |
|
46 |
|
|
47 |
- name: Gather Cluster VPC facts |
|
48 |
ec2_vpc_net_facts: |
|
49 |
filters: |
|
50 |
tag:Name: "{{ cluster_vpc_name }}" |
|
51 |
region: "{{ aws_region_final | default(aws_region) }}" |
|
52 |
register: cluster_vpc |
|
53 |
failed_when: cluster_vpc.vpcs | length == 0 |
|
54 |
|
|
55 |
- name: Remove Private DNS Entry for IdM in cluster private zone |
|
56 |
route53: |
|
57 |
state: absent |
|
58 |
private_zone: yes |
|
59 |
record: "{{ idm_dns_name }}" |
|
60 |
type: A |
|
61 |
ttl: 60 |
|
62 |
value: "{{ ec2instance.public_ip_address }}" |
|
63 |
zone: "{{ cluster_name }}{{ subdomain_base_suffix }}." |
|
64 |
vpc_id: "{{ cluster_vpc.vpcs[0].vpc_id }}" |
|
65 |
|
0d0d0e
|
66 |
- name: Remove Certificate renewal cronjob |
JR |
67 |
cron: |
|
68 |
name: LETS_ENCRYPT_RENEW_IDM |
|
69 |
state: absent |
|
70 |
|
bf4161
|
71 |
# Leave this as the last task in the playbook. |
JR |
72 |
- name: remove_workload tasks complete |
|
73 |
debug: |
|
74 |
msg: "Remove Workload tasks completed successfully." |
|
75 |
when: not silent|bool |