Skip to content

Commit 02ff055

Browse files
Merge pull request #92 from aanriot/master
Allow to use external zone files
2 parents a255584 + 1b421d8 commit 02ff055

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

README.rst

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ Install the bind package and start the bind service.
2424
---------------
2525

2626
Manage the bind configuration file.
27-
This state can generate some basic zone files if a `records` entry is found in the
28-
`available_zones`' declaration for the zone (see `pillar.example` for how to write these)
2927

3028
Example Pillar
3129
==============
@@ -52,23 +50,6 @@ Example Pillar
5250
cat: 2.3.4.188
5351
rat: 1.2.3.231
5452
live: 1.2.3.236
55-
56-
See *bind/pillar.example* for a more complete example.
57-
58-
On the other hand, if no `records` entry exists, the zone file is not generated by this state
59-
rather than taken from `salt://zones`. See `pillar.example` for how to overwrite
60-
this URL.
61-
62-
Example Pillar
63-
==============
64-
65-
.. code:: yaml
66-
67-
bind:
68-
configured_zones:
69-
sub.domain.com:
70-
type: master
71-
notify: False
7253
configured_views:
7354
myview1:
7455
match_clients:
@@ -79,7 +60,38 @@ Example Pillar
7960
type: master
8061
notify: False
8162
82-
See *bind/pillar.example*.
63+
See *bind/pillar.example* for a more complete example.
64+
65+
Management of zone files
66+
========================
67+
68+
`named.conf.local`
69+
------------------
70+
71+
<zone> entries in `named.conf.local` will point to the file declared in
72+
73+
* `bind:configured_zones:<zone>:file` (this takes precedence)
74+
* `bind:available_zones:<zone>:file`
75+
76+
zone files
77+
----------
78+
79+
The `config.sls` state will iterate on `bind:available_zones` and manage
80+
<zone> files for each <zone> that has bind:available_zones:<zone>:file`
81+
declared.
82+
83+
* If `bind:available_zones:<zone>:records` exist, a zone file will be created
84+
using those records (see pillar.example for more details)
85+
* If `bind:available_zones:<zone>:records` is **NOT** declared,
86+
`bind:available_zones:<zone>:file` should point to an existing zone file
87+
that will be **sourced** by the formula.
88+
89+
External zone files
90+
-------------------
91+
92+
To use an external tool to manage the <zone> file, simply declare the location
93+
of the zone file in `bind:configured_zones:<zone>:file` and **don't** add any
94+
entry for the <zone> in `bind:available_zones`
8395

8496
Notes
8597
=====

bind/config.sls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ bind_rndc_client_config:
169169
{% endif %}
170170
171171
{% for zone, zone_data in salt['pillar.get']('bind:configured_zones', {}).items() -%}
172-
{%- set file = salt['pillar.get']("bind:available_zones:" + zone + ":file", zone_data.get('file')) %}
172+
{%- set file = salt['pillar.get']("bind:available_zones:" + zone + ":file"), false %}
173173
{%- set zone_records = salt['pillar.get']('bind:available_zones:' + zone + ':records', {}) %}
174174
{# If we define RRs in pillar, we use the internal template to generate the zone file
175175
otherwise, we fallback to the old behaviour and use the declared file
@@ -208,7 +208,7 @@ signed-{{ zone }}:
208208
209209
{%- for view, view_data in salt['pillar.get']('bind:configured_views', {}).items() %}
210210
{% for zone, zone_data in view_data.get('configured_zones', {}).items() -%}
211-
{%- set file = salt['pillar.get']("bind:available_zones:" + zone + ":file", zone_data.get('file')) %}
211+
{%- set file = salt['pillar.get']("bind:available_zones:" + zone + ":file"), false %}
212212
{%- set zone_records = salt['pillar.get']('bind:available_zones:' + zone + ':records', {}) %}
213213
{# If we define RRs in pillar, we use the internal template to generate the zone file
214214
otherwise, we fallback to the old behaviour and use the declared file

0 commit comments

Comments
 (0)