-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure-route53.yml
65 lines (61 loc) · 2.13 KB
/
configure-route53.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
- hosts: localhost
vars:
terraform_workspace: default
tasks:
- name: Setup Route 53 host zones
vars:
ansible_python_interpreter: /usr/bin/python3
amazon.aws.route53:
access_key: "{{ lookup('ansible.builtin.env', 'AWS_ROUTE53_KEY_ID') | default('') }}"
secret_key: "{{ lookup('ansible.builtin.env', 'AWS_ROUTE53_SECRET_KEY') | default('') }}"
state: present
zone: data.nesi.org.nz
record: "{{ item.domain }}.data.nesi.org.nz"
type: A
ttl: 60
value: "{{ item.dest }}"
wait: true
overwrite: true
loop:
- domain: "{{ hostvars['servicesnode']['hostname'] }}"
dest: "{{ hostvars['servicesnode']['ansible_host'] }}"
- domain: "{{ hostvars['webnode']['hostname'] }}"
dest: "{{ hostvars['webnode']['ansible_host'] }}"
when: (operation == "create")
- name: Create Route 53 host list
file:
path: "users/domains.txt"
state: touch
when: (operation == "create")
- name: Insert Route 53 hosts
lineinfile:
path: "users/domains.txt"
line: "{{ item.domain }}.data.nesi.org.nz"
loop:
- domain: "{{ hostvars['servicesnode']['hostname'] }}"
dest: "{{ hostvars['servicesnode']['ansible_host'] }}"
- domain: "{{ hostvars['webnode']['hostname'] }}"
dest: "{{ hostvars['webnode']['ansible_host'] }}"
when: (operation == "create")
- name: Remove Route 53 host zones
vars:
ansible_python_interpreter: /usr/bin/python3
amazon.aws.route53:
access_key: "{{ lookup('ansible.builtin.env', 'AWS_ROUTE53_KEY_ID') | default('') }}"
secret_key: "{{ lookup('ansible.builtin.env', 'AWS_ROUTE53_SECRET_KEY') | default('') }}"
state: absent
zone: data.nesi.org.nz
record: "{{ item.domain }}.data.nesi.org.nz"
type: A
ttl: 60
wait: true
loop:
- domain: "{{ terraform_workspace }}-ood-services"
- domain: "{{ terraform_workspace }}-ood-webnode"
when: (operation == "destroy")
ignore_errors: true
- name: Cleanup Route 53 host list
file:
path: "users/domains.txt"
state: absent
when: (operation == "destroy")