aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/wireguard
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-12-29 00:54:33 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2018-12-29 00:54:33 +0100
commit9297d5731f8f069c719a9b8812a4fa92cd2a07c0 (patch)
tree911101f17db95c5061f1b5b91098fdfdaf4f39a0 /ansible/roles/wireguard
parent17a6c2aa2c5610860da11ad242aa8c79507442a2 (diff)
downloadinfra-9297d5731f8f069c719a9b8812a4fa92cd2a07c0.tar.gz
infra-9297d5731f8f069c719a9b8812a4fa92cd2a07c0.tar.bz2
infra-9297d5731f8f069c719a9b8812a4fa92cd2a07c0.tar.xz
infra-9297d5731f8f069c719a9b8812a4fa92cd2a07c0.zip
wireguard: Creating DNS records file.
Diffstat (limited to 'ansible/roles/wireguard')
-rw-r--r--ansible/roles/wireguard/tasks/main.yml20
1 files changed, 20 insertions, 0 deletions
diff --git a/ansible/roles/wireguard/tasks/main.yml b/ansible/roles/wireguard/tasks/main.yml
index a663be3..9d87c5b 100644
--- a/ansible/roles/wireguard/tasks/main.yml
+++ b/ansible/roles/wireguard/tasks/main.yml
@@ -133,3 +133,23 @@
rule: allow
port: "{{ wireguard__listen_port }}"
proto: udp
+
+- name: generate dns records
+ tags: wireguard-dns-records
+ when: wireguard__role == 'server'
+ local_action:
+ module: copy
+ content: |
+ wireguard_dns_records_{{ wireguard__net_id }}:
+ {% for c in wireguard__clients|sort %}
+ {% set client = wireguard__clients[c] %}
+ - type: A
+ name: {{ c }}
+ value: {{ client.ipv4 }}
+ state: {{ client.state }}
+ - type: AAAA
+ name: {{ c }}
+ value: {{ client.ipv6 }}
+ state: {{ client.state }}
+ {% endfor %}
+ dest: "files/wireguard-dns-records-{{ wireguard__net_id }}.yml"