diff --git a/defaults/main.yml b/defaults/main.yml index 85c8864..85eda6f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -164,6 +164,13 @@ dhcpd_options: False dhcpd_keys: [] +# .. envvar:: dhcpd_zones +# +# List of DNS zones to update with Dynamic DNS configuration. See +# :ref:`dhcpd_zones` for more details. +dhcpd_zones: [] + + # .. envvar:: dhcpd_classes # # List of client classes (see dhcpd.conf(5)). More informaction can be found in diff --git a/docs/defaults-configuration.rst b/docs/defaults-configuration.rst index 761615f..3355182 100644 --- a/docs/defaults-configuration.rst +++ b/docs/defaults-configuration.rst @@ -43,6 +43,35 @@ Examples:: secret: "{{ dhcpd_secret_secure_key }}" +.. _dhcpd_zones: + +dhcpd_zones +----------- + +This list lets you define DNS zones used to update dynamic DNS with information +configured using DHCP. + +``zone`` + DNS domain name of a zone, needs to end with a dot (``.``) + +``primary`` + Address of the primary DNS server serving the specified zone + +``key`` + Name of the symmetric key used to authorize Dynamic DNS updates of the + specified zone + +``comment`` + An optional comment added in the configuration file + +Examples:: + + dhcpd_zones: + - zone: "example.org." + primary: "127.0.0.1" + key: "secure-key" + + .. _dhcpd_classes: dhcpd_classes diff --git a/templates/etc/dhcp/dhcpd.conf.j2 b/templates/etc/dhcp/dhcpd.conf.j2 index 17b1902..8228928 100644 --- a/templates/etc/dhcp/dhcpd.conf.j2 +++ b/templates/etc/dhcp/dhcpd.conf.j2 @@ -32,6 +32,11 @@ log-facility {{ dhcpd_log_facility }}; {{ print.key(key) }} {% endfor %} {% endif %} +{% if dhcpd_zones is defined and dhcpd_zones %} +{% for zone in dhcpd_zones %} +{{ print.zone(zone) }} +{% endfor %} +{% endif %} {% if dhcpd_classes is defined and dhcpd_classes %} {% for class in dhcpd_classes %} {{ print.class(class) }} diff --git a/templates/etc/dhcp/macros.j2 b/templates/etc/dhcp/macros.j2 index 6fa05cf..ae28e60 100644 --- a/templates/etc/dhcp/macros.j2 +++ b/templates/etc/dhcp/macros.j2 @@ -211,8 +211,21 @@ failover peer "{{ failover.failover }}" { {% if key.comment is defined and key.comment %} # {{ key.comment }} {% endif %} -key "{{ key.key }}" { +key {{ key.key }} { algorithm {{ key.algorithm|default('hmac-md5') }}; secret {{ key.secret }}; } {% endmacro %} +{# +# +# ---- Macro: print.zone() ---- +#} +{% macro zone(zone) %} +{% if zone.comment is defined and zone.comment %} +# {{ zone.comment }} +{% endif %} +zone {{ zone.zone }} { + primary {{ zone.primary }}; + key {{ zone.key }}; +} +{% endmacro %}