Commit 9b9a9e23 authored by nanahira's avatar nanahira

rework dnsmasq template

parent 41c84279
{% macro setDomainAndKMS(br, domain) %}
## Using domain {{domain}}
domain={{domain}},{{br.address}},local
{% if dnsmasq.kms is defined and dnsmasq.kms %}
### KMS
{% if dnsmasq.kms != "localhost" %}
#### Using self-hosted KMS
srv-host=_vlmcs._tcp.{{domain}},{{dnsmasq.kms}},1688,0,100
{% else %}
#### Using in-built KMS
srv-host=_vlmcs._tcp.{{domain}},{{services.address}},1688,0,100
{% endif %}
{% endif %}
## End domain {{domain}}
{% endmacro %}
{% macro setAptCacher(address) %}
#### Using apt cacher {{address}}
local=/archive.ubuntu.com/security.ubuntu.com/deb.debian.org/security.debian.org/
address=/archive.ubuntu.com/{{address}}
host-record=security.ubuntu.com,deb.debian.org,security.debian.org,{{address}}
{% endmacro %}
{% macro setNetbootPXE(interface, address) %}
#### Using Netboot PXE server {{address}} for interface {{interface}}
dhcp-match=set:bios,60,PXEClient:Arch:00000
dhcp-match=set:efi32,60,PXEClient:Arch:00002
dhcp-match=set:efi32-1,60,PXEClient:Arch:00006
dhcp-match=set:efi64,60,PXEClient:Arch:00007
dhcp-match=set:efi64-1,60,PXEClient:Arch:00008
dhcp-match=set:efi64-2,60,PXEClient:Arch:00009
tag-if=tag:{{interface}},tag:bios,set:bios-{{interface}}
tag-if=tag:{{interface}},tag:efi32,set:efi32-{{interface}}
tag-if=tag:{{interface}},tag:efi32-1,set:efi32-1-{{interface}}
tag-if=tag:{{interface}},tag:efi64,set:efi64-{{interface}}
tag-if=tag:{{interface}},tag:efi64-1,set:efi64-1-{{interface}}
tag-if=tag:{{interface}},tag:efi64-2,set:efi64-2-{{interface}}
dhcp-boot=tag:bios-{{interface}},netboot.xyz.kpxe,,{{ address }}
dhcp-boot=tag:efi32-{{interface}},netboot.xyz.efi,,{{ address }}
dhcp-boot=tag:efi32-1-{{interface}},netboot.xyz.efi,,{{ address }}
dhcp-boot=tag:efi64-{{interface}},netboot.xyz.efi,,{{ address }}
dhcp-boot=tag:efi64-1-{{interface}},netboot.xyz.efi,,{{ address }}
dhcp-boot=tag:efi64-2-{{interface}},netboot.xyz.efi,,{{ address }}
{% endmacro %}
# MyCard NextGen Router DNSMasq config file
server=127.0.0.1#55553 server=127.0.0.1#55553
no-resolv no-resolv
strict-order strict-order
...@@ -13,16 +58,6 @@ enable-ra ...@@ -13,16 +58,6 @@ enable-ra
no-dhcp-interface=lo{% for br in bridges %}{% if not br.dhcp is defined or not br.dhcp %},{{br.name}}{% endif %}{% endfor %}{% if dnsmasq.extraInterfaces is defined %}{% for interface in dnsmasq.extraInterfaces %},{{interface}}{% endfor %}{% endif %} no-dhcp-interface=lo{% for br in bridges %}{% if not br.dhcp is defined or not br.dhcp %},{{br.name}}{% endif %}{% endfor %}{% if dnsmasq.extraInterfaces is defined %}{% for interface in dnsmasq.extraInterfaces %},{{interface}}{% endfor %}{% endif %}
{% if dnsmasq.pxe is defined and dnsmasq.pxe %}
# PXE match detection
dhcp-match=set:bios,60,PXEClient:Arch:00000
dhcp-match=set:efi32,60,PXEClient:Arch:00002
dhcp-match=set:efi32-1,60,PXEClient:Arch:00006
dhcp-match=set:efi64,60,PXEClient:Arch:00007
dhcp-match=set:efi64-1,60,PXEClient:Arch:00008
dhcp-match=set:efi64-2,60,PXEClient:Arch:00009
{% endif %}
{% for br in bridges %} {% for br in bridges %}
{% if br.dhcp is defined and br.dhcp %} {% if br.dhcp is defined and br.dhcp %}
# DHCP for {{br.name}} # DHCP for {{br.name}}
...@@ -30,36 +65,10 @@ dhcp-range={{br.name}},{{br.dhcp.start}},{{br.dhcp.end}},{{br.dhcp.time}} ...@@ -30,36 +65,10 @@ dhcp-range={{br.name}},{{br.dhcp.start}},{{br.dhcp.end}},{{br.dhcp.time}}
{% if br.dhcp.domain is defined and br.dhcp.domain %} {% if br.dhcp.domain is defined and br.dhcp.domain %}
## Domain {{br.dhcp.domain}} specified ## Domain {{br.dhcp.domain}} specified
domain={{br.dhcp.domain}},{{br.address}},local {{setDomainAndKMS(br, br.dhcp.domain)}}
{% if dnsmasq.kms is defined and dnsmasq.kms %}
### KMS
{% if dnsmasq.kms != "localhost" %}
#### Using self-hosted KMS
srv-host=_vlmcs._tcp.{{br.dhcp.domain}},{{dnsmasq.kms}},1688,0,100
{% else %}
#### Using in-built KMS
srv-host=_vlmcs._tcp.{{br.dhcp.domain}},{{services.address}},1688,0,100
{% endif %}
{% endif %}
{% else %} {% else %}
## Domain not specified, using default domain {{br.name | regex_replace('^(vm)?br', '')}}.lan ## Domain not specified, using default domain {{br.name | regex_replace('^(vm)?br', '')}}.lan
domain={{br.name | regex_replace('^(vm)?br', '')}}.lan,{{br.address}},local {{setDomainAndKMS(br, (br.name | regex_replace('^(vm)?br', '')) + '.lan')}}
{% if dnsmasq.kms is defined and dnsmasq.kms %}
### KMS
{% if dnsmasq.kms != "localhost" %}
#### Using self-hosted KMS
srv-host=_vlmcs._tcp.{{br.name | regex_replace('^(vm)?br', '')}}.lan,{{dnsmasq.kms}},1688,0,100
{% else %}
#### Using in-built KMS
srv-host=_vlmcs._tcp.{{br.name | regex_replace('^(vm)?br', '')}}.lan,{{services.address}},1688,0,100
{% endif %}
{% endif %}
## end domain for {{br.name}}
{% endif %} {% endif %}
{% if br.dhcpv6Receive is defined and br.dhcpv6Receive %} {% if br.dhcpv6Receive is defined and br.dhcpv6Receive %}
...@@ -68,14 +77,6 @@ dhcp-range=tag:{{br.name}},::,constructor:{{br.name}},ra-names,24h ...@@ -68,14 +77,6 @@ dhcp-range=tag:{{br.name}},::,constructor:{{br.name}},ra-names,24h
{% endif %} {% endif %}
## PXE server for {{br.name}} ## PXE server for {{br.name}}
### Tag detection
tag-if=tag:{{br.name}},tag:bios,set:bios-{{br.name}}
tag-if=tag:{{br.name}},tag:efi32,set:efi32-{{br.name}}
tag-if=tag:{{br.name}},tag:efi32-1,set:efi32-1-{{br.name}}
tag-if=tag:{{br.name}},tag:efi64,set:efi64-{{br.name}}
tag-if=tag:{{br.name}},tag:efi64-1,set:efi64-1-{{br.name}}
tag-if=tag:{{br.name}},tag:efi64-2,set:efi64-2-{{br.name}}
{% if br.dhcp.pxe is defined and br.dhcp.pxe %} {% if br.dhcp.pxe is defined and br.dhcp.pxe %}
### Using br-specified PXE server {{ br.dhcp.pxe.address }} {{ br.dhcp.pxe.file }} ### Using br-specified PXE server {{ br.dhcp.pxe.address }} {{ br.dhcp.pxe.file }}
dhcp-boot=tag:{{br.name}},{{ br.dhcp.pxe.file }},,{{ br.dhcp.pxe.address }} dhcp-boot=tag:{{br.name}},{{ br.dhcp.pxe.file }},,{{ br.dhcp.pxe.address }}
...@@ -87,28 +88,13 @@ dhcp-boot=tag:{{br.name}},{{ br.dhcp.pxe.file }},,{{ br.dhcp.pxe.address }} ...@@ -87,28 +88,13 @@ dhcp-boot=tag:{{br.name}},{{ br.dhcp.pxe.file }},,{{ br.dhcp.pxe.address }}
dhcp-boot=tag:{{br.name}},{{ dnsmasq.pxe.file }},,{{ dnsmasq.pxe.address }} dhcp-boot=tag:{{br.name}},{{ dnsmasq.pxe.file }},,{{ dnsmasq.pxe.address }}
{% elif dnsmasq.pxe == "localhost" or (dnsmasq.pxe.localhost is defined and dnsmasq.pxe.localhost) %} {% elif dnsmasq.pxe == "localhost" or (dnsmasq.pxe.localhost is defined and dnsmasq.pxe.localhost) %}
#### Use in-built netboot PXE server #### Use in-built netboot PXE server
dhcp-boot=tag:bios-{{br.name}},netboot.xyz.kpxe,,{{ br.address | regex_replace("/\d+$", "") }} {{setNetbootPXE(br.name, br.address | regex_replace("/\d+$", ""))}}
dhcp-boot=tag:efi32-{{br.name}},netboot.xyz.efi,,{{ br.address | regex_replace("/\d+$", "") }}
dhcp-boot=tag:efi32-1-{{br.name}},netboot.xyz.efi,,{{ br.address | regex_replace("/\d+$", "") }}
dhcp-boot=tag:efi64-{{br.name}},netboot.xyz.efi,,{{ br.address | regex_replace("/\d+$", "") }}
dhcp-boot=tag:efi64-1-{{br.name}},netboot.xyz.efi,,{{ br.address | regex_replace("/\d+$", "") }}
dhcp-boot=tag:efi64-2-{{br.name}},netboot.xyz.efi,,{{ br.address | regex_replace("/\d+$", "") }}
{% elif dnsmasq.pxe.address is defined and dnsmasq.pxe.address %} {% elif dnsmasq.pxe.address is defined and dnsmasq.pxe.address %}
#### Use remote netboot PXE server #### Use remote netboot PXE server
dhcp-boot=tag:bios-{{br.name}},netboot.xyz.kpxe,,{{dnsmasq.pxe.address}} {{setNetbootPXE(br.name, dnsmasq.pxe.address)}}
dhcp-boot=tag:efi32-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe.address}}
dhcp-boot=tag:efi32-1-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe.address}}
dhcp-boot=tag:efi64-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe.address}}
dhcp-boot=tag:efi64-1-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe.address}}
dhcp-boot=tag:efi64-2-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe.address}}
{% else %} {% else %}
#### Use remote netboot PXE server #### Use remote netboot PXE server
dhcp-boot=tag:bios-{{br.name}},netboot.xyz.kpxe,,{{dnsmasq.pxe}} {{setNetbootPXE(br.name, dnsmasq.pxe)}}
dhcp-boot=tag:efi32-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi32-1-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi64-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi64-1-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi64-2-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe}}
{% endif %} {% endif %}
{% else %} {% else %}
...@@ -121,16 +107,12 @@ dhcp-boot=tag:efi64-2-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe}} ...@@ -121,16 +107,12 @@ dhcp-boot=tag:efi64-2-{{br.name}},netboot.xyz.efi,,{{dnsmasq.pxe}}
{% if dnsmasq.aptCacher is defined and dnsmasq.aptCacher %} {% if dnsmasq.aptCacher is defined and dnsmasq.aptCacher %}
# apt cacher # apt cacher
local=/archive.ubuntu.com/security.ubuntu.com/deb.debian.org/security.debian.org/
{% if dnsmasq.aptCacher != "localhost" %} {% if dnsmasq.aptCacher != "localhost" %}
## In-built apt cacher ## In-built apt cacher
address=/archive.ubuntu.com/{{dnsmasq.aptCacher}} {{setAptCacher(dnsmasq.aptCacher)}}
host-record=security.ubuntu.com,deb.debian.org,security.debian.org,{{dnsmasq.aptCacher}}
{% else %} {% else %}
## Remote apt cacher ## Remote apt cacher
address=/archive.ubuntu.com/{{services.address}} {{setAptCacher(services.address)}}
host-record=security.ubuntu.com,deb.debian.org,security.debian.org,{{services.address}}
{% endif %} {% endif %}
{% endif %} {% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment