This commit is contained in:
Jukka Nousiainen 2021-07-25 09:25:31 +03:00 committed by Andreas B. Mundt
parent 1a0b2614bc
commit bf265a8309
5 changed files with 13 additions and 18 deletions

View file

@ -18,7 +18,8 @@
## LAN IP address range: ## LAN IP address range:
ipaddr_lan: 192.168.0.10/24 ipaddr_lan: 192.168.0.10/24
ipaddr_lan_threeoct: "{{ ipaddr_lan.split('.')[0:3] | join('.') }}" ipaddr_lan_threeoct: "{{ ipaddr_lan.split('.')[0:3] | join('.') }}"
ipaddr_lan_ptr: "{{ ipaddr_lan | ansible.netcommon.ipaddr('revdns').split('.')[1:-1] | join('.') }}" ipaddr_lan_ptr: "{{ (ipaddr_lan | ipaddr('revdns')).split('.')[1:] | join('.') }}"
ipaddr_lan_ptr_threeoct: "{{ ipaddr_lan_ptr.split('.')[0:3] | join('.') }}"
dhcp_range: 192.168.0.50,192.168.0.99,2h dhcp_range: 192.168.0.50,192.168.0.99,2h
di_dist: "{{ ansible_distribution_release }}" di_dist: "{{ ansible_distribution_release }}"

View file

@ -42,10 +42,15 @@
dest: "/etc/bind/{{ item }}" dest: "/etc/bind/{{ item }}"
loop: loop:
- db.intern - db.intern
- db.lan
- localzones - localzones
notify: restart bind notify: restart bind
- name: deploy config files for bind9 - special case where template destination filename is dynamic
template:
src: db.lan.j2
dest: "/etc/bind/db.{{ ipaddr_lan_threeoct }}"
notify: restart bind
- name: link zone files to writeable directory for DDNS - name: link zone files to writeable directory for DDNS
file: file:
src: "/etc/bind/{{ item }}" src: "/etc/bind/{{ item }}"
@ -53,7 +58,7 @@
state: link state: link
loop: loop:
- db.intern - db.intern
- db.lan - "db.{{ ipaddr_lan_threeoct }}"
notify: restart bind notify: restart bind
- name: enable local bind config - name: enable local bind config

View file

@ -1,11 +0,0 @@
$TTL 500
@ IN SOA {{ ansible_fqdn }}. root.{{ ansible_domain }}. (
1 ; Serial
3600 ; Refresh
1800 ; Retry
720000 ; Expire
6400 ) ; Negative Cache TTL
;
@ NS {{ ansible_fqdn }}.
MX 10 {{ ansible_fqdn }}.
{{ ipaddr_lan | ipaddr("address") | regex_replace("^.*\.(.+$)", "\\1") }} PTR {{ ansible_fqdn }}.

View file

@ -26,7 +26,7 @@ zone intern. {
key rndc-key; key rndc-key;
} }
zone "{{ ipaddr_lan_ptr }}" { zone {{ ipaddr_lan_ptr }} {
primary 127.0.0.1; primary 127.0.0.1;
key rndc-key; key rndc-key;
} }
@ -50,7 +50,7 @@ if option arch = 00:07 {
filename "d-i/n-a/pxelinux.0"; filename "d-i/n-a/pxelinux.0";
} }
subnet {{ ipaddr_lan | ipaddr("address") }} netmask {{ ipaddr_lan | ipaddr("netmask") }} { subnet {{ ipaddr_lan | ipaddr("network") }} netmask {{ ipaddr_lan | ipaddr("netmask") }} {
option routers {{ ipaddr_lan | ipaddr("address") }}; option routers {{ ipaddr_lan | ipaddr("address") }};
range {{ dhcp_start }} {{ dhcp_stop }}; range {{ dhcp_start }} {{ dhcp_stop }};
} }

View file

@ -1,6 +1,6 @@
include "/etc/bind/rndc.key"; include "/etc/bind/rndc.key";
zone "{{ ipaddr_lan_ptr }}" { zone "{{ ipaddr_lan_ptr[:-1] }}" {
type master; type master;
notify no; notify no;
file "/etc/bind/db.{{ ipaddr_lan_threeoct }}"; file "/etc/bind/db.{{ ipaddr_lan_threeoct }}";