Skip to content
Permalink
Browse files

[debops.unbound] Add support for 'local-zone' conf

  • Loading branch information...
drybjed committed Sep 28, 2019
1 parent 3e06136 commit 1cdf48b768b842c8f26aa80c983f87fcd4f31153
@@ -50,8 +50,18 @@
{% macro print_zone(config) %}
{% set real_zone_name = (config.zone | d(config.name)) %}
{% set zone_name = (real_zone_name + ('.' if not real_zone_name.endswith('.') else '')) %}
{% if config.type|d('forward') == 'local' %}
server:
local-zone: "{{ (zone_name | regex_replace('\n$','') | regex_replace('\.$','')) + '.' }}" {{ config.local_zone_type | d('static') }}
{% if config.local_zone_data|d() %}
{% for record in ([ config.local_zone_data ] if (config.local_zone_data is string) else config.local_zone_data) %}
local-data: "{{ ((zone_name | regex_replace('\n$','') | regex_replace('\.$','')) + '. ') + record | regex_replace('\n$','') }}"
{% endfor %}
{% endif %}
{% else %}
{{ config.type | d('forward') }}-zone:
name: "{{ zone_name }}"
{% endif %}
{% if unbound__tpl_nameservers %}
{% for entry in unbound__tpl_nameservers %}
{{ config.type | d('forward') }}-addr: {{ entry }}
@@ -40,9 +40,21 @@ Each list entry is a YAML dictionary with specific parameters:
a particular delegation.

``type``
Optional. The zone type to use, either ``forward`` (default if not specified)
or ``stub``. See the :man:`unbound.conf(5)` for details about stub and
forward zones.
Optional. The zone type to use, either ``forward`` (default if not
specified), ``local`` or ``stub``. See the :man:`unbound.conf(5)` for details
about stub and forward zones.

``local_zone_type``
Optional. If the ``type`` parameter is set to ``local``, this parameter can
be used to define the type of the local zone (``static`` (default),
``transparent``, etc. See :man:`unbound.conf(5)` manual page, ``local-zone:``
keyword for the details about local zone types.

``local_zone_data``
Optional. If the ``type`` parameter is set to ``local``, this parameter can
be used to define the data of a given local zone. This is a YAML list of
entries, each entry can specify a DNS Resource Record as a string. See the
examples section for an example local zone configuration.

``nameserver``, ``nameservers``
Optional. IP address or list of IP addresses of the DNS nameservers of
@@ -108,3 +120,20 @@ Create custom forward zone for internal network:
nameserver: '192.0.2.1'
options:
- 'forward-first': True
Define a local DNS entry ``example.test.`` with a few resource records:

.. code-block:: yaml
unbound__zones:
- name: 'example.test'
zone: 'example.test.'
type: 'local'
local_zone_type: 'static'
local_zone_data:
- 'NS localhost.'
- 'SOA localhost. nobody.invalid. 1 3600 1200 604800 10800'
- 'PTR localhost.'
- 'A 192.0.2.1'
- 'AAAA 2001:db8::1'

0 comments on commit 1cdf48b

Please sign in to comment.
You can’t perform that action at this time.