diff --git a/roles/dnsmasq/tasks/main.yml b/roles/dnsmasq/tasks/main.yml index 81a8c66..99d416d 100644 --- a/roles/dnsmasq/tasks/main.yml +++ b/roles/dnsmasq/tasks/main.yml @@ -2,9 +2,10 @@ package: name: - dnsmasq - - bind-tools - - krb5 - - py3-pexpect + - bind-tools # for DNS updates + - krb5 # for DNS updates + - py3-pexpect # for creating kerberos keytab + - sqlite # for lease DB - name: Configure kerberos template: @@ -23,11 +24,11 @@ args: creates: /etc/krb5.keytab -- name: Copy DNS updater script +- name: Copy DHCP lease script template: - dest: "/usr/local/bin/dns-update" - src: "dns-update.j2" - mode: 0700 + dest: "/usr/local/bin/dnsmasq-script" + src: "dnsmasq-script.j2" + mode: 0755 - name: Configure dnsmasq template: diff --git a/roles/dnsmasq/templates/00-options.conf.j2 b/roles/dnsmasq/templates/00-options.conf.j2 index 3e505e9..0bcaa7f 100644 --- a/roles/dnsmasq/templates/00-options.conf.j2 +++ b/roles/dnsmasq/templates/00-options.conf.j2 @@ -18,4 +18,8 @@ interface = {{ interfaces | map(attribute='name') | join(',') }} dhcp-option = option:dns-server,{{ dns | join(',') }} dhcp-option = option:ntp-server,{{ ntp | join(',') }} -dhcp-script = /usr/local/bin/dns-update +dhcp-script = /usr/local/bin/dnsmasq-script +dhcp-scriptuser = dnsmasq + +# track leases with dnsmasq-script instead +leasefile-ro diff --git a/roles/dnsmasq/templates/dns-update.j2 b/roles/dnsmasq/templates/dns-update.j2 deleted file mode 100644 index 89ac0c2..0000000 --- a/roles/dnsmasq/templates/dns-update.j2 +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -# don’t spam the DNS server when starting dnsmasq -if [ -n "${DNSMASQ_INTERFACE}" ] ; then - exit -fi - -domain={{ domain }} -ldap_user={{ password.ldap_user }} -ttl=3600 - -address="${3}" - -case "${1}" in -add) - host="${4}" - kinit -k "${ldap_user}" - nsupdate -g <