aboutsummaryrefslogtreecommitdiff
path: root/ansible/plays/ipam-generate-dns.yml
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/plays/ipam-generate-dns.yml')
-rw-r--r--ansible/plays/ipam-generate-dns.yml32
1 files changed, 32 insertions, 0 deletions
diff --git a/ansible/plays/ipam-generate-dns.yml b/ansible/plays/ipam-generate-dns.yml
new file mode 100644
index 0000000..d29b3e8
--- /dev/null
+++ b/ansible/plays/ipam-generate-dns.yml
@@ -0,0 +1,32 @@
+- hosts: localhost
+ gather_facts: no
+ connection: local
+ tasks:
+ - set_fact:
+ content: |
+ {% set hosts = [] %}
+ {% for nw_name, network in ipam6.networks.items() %}
+ {% for host, address in (network.hosts|default({})).items() %}
+ {{- hosts.append({'name': host, 'address': address}) -}}
+ {% endfor %}
+ {% endfor %}
+ # Generated from ansible data
+ {% for h in hosts|sort(attribute='name') %}
+
+ resource "linode_domain_record" "dn42-{{ h.name }}" {
+ domain_id = linode_domain.root.id
+ name = "{{ h.name }}.dn42"
+ record_type = "AAAA"
+ target = "{{ h.address|ansible.utils.ipv6('address') }}"
+ }
+ {% endfor %}
+ - debug:
+ msg: "{{ content }}"
+ when: false
+ - name: Generating ../../terraform/dns/dn42.tf
+ register: tf
+ copy:
+ dest: ../../terraform/dns/dn42.tf
+ content: "{{ content }}"
+ - shell: terraform fmt ../../terraform/ipam6/ipam6.tf
+ when: "tf.changed"