-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdyndns.yml
50 lines (41 loc) · 1.26 KB
/
dyndns.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
---
# Version 1.0.0
- hosts: "localhost"
gather_facts: true
vars:
dns_zone: "mydomain.com"
dyndns_names:
- "dyndns"
dyndns_ttl: 300
api_key: ""
external_ip_address: ""
# DO NOT SET!
dns_record_id: "" # Do not set!
dns_record_type: "" # Do not set!
tasks:
- name: Assert that external IP Address is set
ansible.builtin.assert:
that: "{{ external_ip_address | length > 0 }}"
fail_msg: "It seems that you haven't provided an external IP Address."
success_msg: "IP Address provided. Proceeding."
- name: Get Zone ID for {{ dns_zone }}
ansible.builtin.uri:
url: "https://dns.hetzner.com/api/v1/zones?name={{ dns_zone }}"
method: GET
headers:
Auth-API-Token: "{{ api_key }}"
register: zone_id
- name: Get all DNS Records for Zone {{ dns_zone }}
ansible.builtin.uri:
url: "https://dns.hetzner.com/api/v1/records?zone_id={{ zone_id.json.zones[0].id }}"
method: GET
headers:
Auth-API-Token: "{{ api_key }}"
register: dns_records
# - debug:
# var: dns_records
- name: Manage Record
include_tasks: manage_record.yml
loop: "{{ dyndns_names }}"
loop_control:
loop_var: dyndns_name