-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdns.yaml
72 lines (61 loc) · 2.17 KB
/
dns.yaml
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
---
- hosts: localhost
gather_facts: no
vars:
hostname: "{{ custID + '.' + baseDomain }}"
subZone: "cna.ukcloud"
apiDnsRecords:
- api
ingressDnsRecords:
- "*.apps"
tasks:
- name: Determine zone
set_fact:
zone: "{{ subZone + baseDomain.split(subZone | string)[1] }}"
- name: Split hostname
set_fact:
clusterPrefix: "{{ hostname.split(zone | string)[0] }}"
- include_tasks: tasks/dns-retrieve-user-token.yaml
- include_tasks: tasks/dns-verify-zone-exists.yaml
- name: Verify if API record exists
include_tasks: tasks/dns-verify-record.yaml
with_items: "{{ apiDnsRecords | first }}"
vars:
uriMethod: "GET"
uriStatusCode: "200,404"
dnsRecordType: "A"
- name: Fail when API record exists but IP address is different
fail:
msg:
"API record exists with IP: {{ verifyRecordOutput.json.rrSets[0].rdata[0] }} provided IP was: {{ apiFIP }}"
when: verifyRecordOutput.status | int == 200 and not verifyRecordOutput.json.rrSets[0].rdata[0] == apiFIP
- name: Create API DNS records
include_tasks: tasks/dns-create-record.yaml
with_items: "{{ apiDnsRecords }}"
vars:
uriMethod: "POST"
uriStatusCode: "201"
dns_record_data: "{{ apiFIP }}"
dnsRecordType: "A"
when: verifyRecordOutput.status | int == 404
- name: Verify if Ingress record exists
include_tasks: tasks/dns-verify-record.yaml
with_items: "{{ ingressDnsRecords | first }}"
vars:
uriMethod: "GET"
uriStatusCode: "200,404"
dnsRecordType: "A"
- name: Fail when Ingress record exists but IP address is different
fail:
msg:
"Ingress record exists with IP: {{ verifyRecordOutput.json.rrSets[0].rdata[0] }} provided IP was: {{ ingressFIP }}"
when: verifyRecordOutput.status | int == 200 and not verifyRecordOutput.json.rrSets[0].rdata[0] == ingressFIP
- name: Create Ingress DNS records
include_tasks: tasks/dns-create-record.yaml
with_items: "{{ ingressDnsRecords }}"
vars:
uriMethod: "POST"
uriStatusCode: "201"
dns_record_data: "{{ ingressFIP }}"
dnsRecordType: "A"
when: verifyRecordOutput.status | int == 404