commit f53a0159a8596e793a527ded8ae6aa8b7832abd8
parent a845342fda73fe5361659f34e66472931f3f36a6
Author: Andreas Gruhler <andreas.gruhler@adfinis-sygroup.ch>
Date: Wed, 8 Jan 2020 10:14:36 +0100
add dnsmasq snippet
Diffstat:
3 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/ansible/dhcp-static-hosts.yml b/ansible/dhcp-static-hosts.yml
@@ -0,0 +1,11 @@
+---
+
+# create dnsmasq config for static ip addresses
+- hosts: local
+ vars:
+ qemu_config: "{{ lookup('file', 'qemu-config.yml') | from_yaml }}"
+ tasks:
+ - name: create dnsmasq config snippet with ip mac mapping
+ template:
+ src: 'templates/dnsmasq.j2'
+ dest: './dnsmasq.conf'
diff --git a/ansible/templates/dnsmasq.j2 b/ansible/templates/dnsmasq.j2
@@ -0,0 +1,5 @@
+# Ansible generated dnsmasq.conf snippet
+{% for host in qemu_config %}
+# pve host {{ host.id }}
+dhcp-host={{ host.macaddr }},{{ host.ip4 }}
+{% endfor %}
diff --git a/terraform/templates/qemu-config.yml.tpl b/terraform/templates/qemu-config.yml.tpl
@@ -2,5 +2,6 @@
%{ for host in hosts ~}
- fqdn: ${host.name}
+ macaddr: ${tolist(host.network)[0]["macaddr"]}
id: ${split("/",host.id)[2]}
%{ endfor ~}
\ No newline at end of file