Commit e0d16134 authored by nanahira's avatar nanahira

update pxe for dnsmasq

parent 48a6d907
---
- hosts: router_nextgen
remote_user: root
vars:
mycard_domains:
- mycard.moe
- momobako.com
- yuzurisa.com
- moecube.com
- moestart.com
- moenext.com
- ygobbs.com
- newwise.com
- my-card.in
- mius.pro
- touhou.cc
tasks:
- name: dnsmasq
import_tasks: ./tasks/dnsmasq.yaml
handlers:
- name: restart_dnsmasq
docker_compose:
project_src: '{{ansible_user_dir}}/nextgen-router/services/dnsmasq'
restarted: true
......@@ -13,14 +13,25 @@ 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 %}
{% 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 %}
{% if br.dhcp is defined and br.dhcp %}
# DHCP for {{br.name}}
dhcp-range={{br.name}},{{br.dhcp.start}},{{br.dhcp.end}},{{br.dhcp.time}}
{% if br.dhcp.domain is defined and br.dhcp.domain %}
## Domain {{br.dhcp.domain}} specified
domain={{br.dhcp.domain}},{{br.address}},local
{% if dnsmasq.kms is defined and dnsmasq.kms %}
### KMS
{% if dnsmasq.kms != "localhost" %}
......@@ -31,9 +42,12 @@ srv-host=_vlmcs._tcp.{{br.dhcp.domain}},{{dnsmasq.kms}},1688,0,100
srv-host=_vlmcs._tcp.{{br.dhcp.domain}},{{services.address}},1688,0,100
{% endif %}
{% endif %}
{% else %}
## Domain not specified, using default domain {{br.name | regex_replace('^(vm)?br', '')}}.lan
domain={{br.name | regex_replace('^(vm)?br', '')}}.lan,{{br.address}},local
{% if dnsmasq.kms is defined and dnsmasq.kms %}
### KMS
{% if dnsmasq.kms != "localhost" %}
......@@ -44,69 +58,83 @@ srv-host=_vlmcs._tcp.{{br.name | regex_replace('^(vm)?br', '')}}.lan,{{dnsmasq.k
srv-host=_vlmcs._tcp.{{br.name | regex_replace('^(vm)?br', '')}}.lan,{{services.address}},1688,0,100
{% endif %}
{% endif %}
{% endif %}
{% if br.dhcpv6Receive is defined and br.dhcpv6Receive %}
dhcp-range=tag:{{br.name}},::,constructor:{{br.name}},ra-names,24h
{% endif %}
{% endif %}
{% endfor %}
{% if dnsmasq.aptCacher is defined and dnsmasq.aptCacher %}
# apt cacher
local=/archive.ubuntu.com/security.ubuntu.com/deb.debian.org/security.debian.org/
{% if dnsmasq.aptCacher != "localhost" %}
address=/archive.ubuntu.com/{{dnsmasq.aptCacher}}
host-record=security.ubuntu.com,deb.debian.org,security.debian.org,{{dnsmasq.aptCacher}}
{% else %}
address=/archive.ubuntu.com/{{services.address}}
host-record=security.ubuntu.com,deb.debian.org,security.debian.org,{{services.address}}
{% endif %}
{% if br.dhcpv6Receive is defined and br.dhcpv6Receive %}
## IPv6
dhcp-range=tag:{{br.name}},::,constructor:{{br.name}},ra-names,24h
{% endif %}
{% if dnsmasq.pxe is defined and dnsmasq.pxe %}
# PXE
## detect PXE type
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
{% if dnsmasq.pxe != "localhost" %}
## remote PXE server
dhcp-boot=tag:bios,netboot.xyz.kpxe,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi32,netboot.xyz.efi,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi32-1,netboot.xyz.efi,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi64,netboot.xyz.efi,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi64-1,netboot.xyz.efi,,{{dnsmasq.pxe}}
dhcp-boot=tag:efi64-2,netboot.xyz.efi,,{{dnsmasq.pxe}}
{% else %}
{% for br in bridges %}
{% if br.dhcp is defined and br.dhcp %}
## 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 %}
### 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 }}
{% elif dnsmasq.pxe is defined and dnsmasq.pxe %}
### Use default PXE server
{% if dnsmasq.pxe.address is defined %}
#### Default PXE server in address/file format
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) %}
#### Use in-built netboot PXE server
dhcp-boot=tag:bios-{{br.name}},netboot.xyz.kpxe,,{{ 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+$", "") }}
{% else %}
#### Use remote netboot PXE server
dhcp-boot=tag:bios-{{br.name}},netboot.xyz.kpxe,,{{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 %}
{% else %}
### No PXE server for {{br.name}}
{% endif %}
# end DHCP for {{br.name}}
{% endif %}
{% endfor %}
{% if dnsmasq.aptCacher is defined and dnsmasq.aptCacher %}
# apt cacher
local=/archive.ubuntu.com/security.ubuntu.com/deb.debian.org/security.debian.org/
{% if dnsmasq.aptCacher != "localhost" %}
## In-built apt cacher
address=/archive.ubuntu.com/{{dnsmasq.aptCacher}}
host-record=security.ubuntu.com,deb.debian.org,security.debian.org,{{dnsmasq.aptCacher}}
{% else %}
## Remote apt cacher
address=/archive.ubuntu.com/{{services.address}}
host-record=security.ubuntu.com,deb.debian.org,security.debian.org,{{services.address}}
{% endif %}
{% endif %}
{% if dnsmasq.ntp is defined and dnsmasq.ntp %}
# NTP
{% if dnsmasq.ntp != "localhost" %}
## In-built NTP server
dhcp-option=42,{{dnsmasq.ntp}}
{% else %}
## Remote NTP server
dhcp-option=42,{{services.address}}
{% endif %}
{% endif %}
......@@ -42,6 +42,9 @@ vars:
end: 10.0.0.240
time: 48h
domain: lan # 该段的缺省域名,默认为 br 的名称
pxe: # 为该段指定特别的PXE服务器
file: somefile.txt
address: 10.0.0.4
- name: brwan
links:
- bond0.2
......@@ -86,7 +89,7 @@ vars:
extraInterfaces: [] # 额外监听的网卡
kms: localhost # kms 服务器的地址,localhost 为自己搭建
aptCacher: 10.0.0.2 # apt-cacher-ng 的地址
pxe: 10.0.0.3 # pxe 服务器的地址,localhost 为自己搭建
pxe: 10.0.0.3 # pxe 服务器的地址,localhost 为自己搭建,也可以是 address/file 对象的格式
ntp: localhost # ntp 服务器的地址,localhost 为自己搭建
gdut: # 校园网特化使用
remote: 10.0.3.6
......
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