From bf265a8309b9f2e79b87b3fb9159b60d0026b757 Mon Sep 17 00:00:00 2001 From: Jukka Nousiainen Date: Sun, 25 Jul 2021 09:25:31 +0300 Subject: [PATCH] Tweaks --- installbox.yml | 5 +++-- roles/dns-dhcp-tftp/tasks/main.yml | 9 +++++++-- roles/dns-dhcp-tftp/templates/db.192.168.0.j2 | 11 ----------- roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 | 4 ++-- roles/dns-dhcp-tftp/templates/localzones.j2 | 2 +- 5 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 roles/dns-dhcp-tftp/templates/db.192.168.0.j2 diff --git a/installbox.yml b/installbox.yml index 6ab32c3..116b271 100644 --- a/installbox.yml +++ b/installbox.yml @@ -17,8 +17,9 @@ ## LAN IP address range: ipaddr_lan: 192.168.0.10/24 - ipaddr_lan_threeoct: "{{ ipaddr_lan.split('.')[0:3] | join('.')}}" - ipaddr_lan_ptr: "{{ ipaddr_lan | ansible.netcommon.ipaddr('revdns').split('.')[1:-1] | join('.') }}" + ipaddr_lan_threeoct: "{{ ipaddr_lan.split('.')[0:3] | 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 di_dist: "{{ ansible_distribution_release }}" diff --git a/roles/dns-dhcp-tftp/tasks/main.yml b/roles/dns-dhcp-tftp/tasks/main.yml index 26f11ec..98d4b00 100644 --- a/roles/dns-dhcp-tftp/tasks/main.yml +++ b/roles/dns-dhcp-tftp/tasks/main.yml @@ -42,10 +42,15 @@ dest: "/etc/bind/{{ item }}" loop: - db.intern - - db.lan - localzones 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 file: src: "/etc/bind/{{ item }}" @@ -53,7 +58,7 @@ state: link loop: - db.intern - - db.lan + - "db.{{ ipaddr_lan_threeoct }}" notify: restart bind - name: enable local bind config diff --git a/roles/dns-dhcp-tftp/templates/db.192.168.0.j2 b/roles/dns-dhcp-tftp/templates/db.192.168.0.j2 deleted file mode 100644 index 3f942c1..0000000 --- a/roles/dns-dhcp-tftp/templates/db.192.168.0.j2 +++ /dev/null @@ -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 }}. diff --git a/roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 b/roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 index aa724b9..cca662e 100644 --- a/roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 +++ b/roles/dns-dhcp-tftp/templates/dhcpd.conf.j2 @@ -26,7 +26,7 @@ zone intern. { key rndc-key; } -zone "{{ ipaddr_lan_ptr }}" { +zone {{ ipaddr_lan_ptr }} { primary 127.0.0.1; key rndc-key; } @@ -50,7 +50,7 @@ if option arch = 00:07 { 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") }}; range {{ dhcp_start }} {{ dhcp_stop }}; } diff --git a/roles/dns-dhcp-tftp/templates/localzones.j2 b/roles/dns-dhcp-tftp/templates/localzones.j2 index 180dbc0..7cd8cb9 100644 --- a/roles/dns-dhcp-tftp/templates/localzones.j2 +++ b/roles/dns-dhcp-tftp/templates/localzones.j2 @@ -1,6 +1,6 @@ include "/etc/bind/rndc.key"; -zone "{{ ipaddr_lan_ptr }}" { +zone "{{ ipaddr_lan_ptr[:-1] }}" { type master; notify no; file "/etc/bind/db.{{ ipaddr_lan_threeoct }}";