Skip to content

Commit

Permalink
Add possibility to manage zone files
Browse files Browse the repository at this point in the history
  • Loading branch information
miska committed Apr 9, 2019
1 parent 0419624 commit 48fa338
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion knot/files/knot.conf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ zone:
{%- for zone_name, zone in server.zone.items() %}
- domain: {{ zone_name }}
{%- for param_name, param_value in zone.items() %}
{%- if param_name != "records" %}
{%- if param_name != "records" and param_name != "soa" %}
{{ param_name }}: {% if param_value is string %}"{{ param_value }}"{% else %}{{ param_value }}{% endif %}
{%- endif %}
{%- endfor %}
Expand Down
16 changes: 16 additions & 0 deletions knot/files/zone
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; This file is managed by Salt
; Do not edit manually!

$ORIGIN {{ zone_name }}.
$TTL {{ ttl|default('3600') }}

@ SOA {{ soa['master'] }}. {{ soa['email'] }}. (
{{ soa.serial }} ; serial
{{ soa.refresh|default('6h') }} ; refresh
{{ soa.retry|default('1h') }} ; retry
{{ soa.expire|default('6h') }} ; expire
{{ soa.minimum|default('6h') }}) ; minimum

{%- for rec in records %}
{{ rec.name }} {{ rec.ttl|default('') }} {{ rec.type }} {{ rec.content }}
{%- endfor %}
22 changes: 22 additions & 0 deletions knot/server.sls
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@ knot_config:
- require:
- pkg: knot_packages
{%- if server.zone is defined %}
{%- for zone_name, zone in server.zone.items() %}
{%- if zone.records is defined %}
{{ zone_name }}_zone:
file.managed:
- name: {{ zone.storage|default('/var/lib/knot') }}/{{ zone_file|default(zone_name + ".zone") }}
- template: jinja
- source: salt://knot/files/zone
- user: knot
- group: knot
- mode: 0600
- require:
- file: knot_config
- context:
zone_name: {{ zone_name }}
soa: {{ zone.soa }}
records: {{ zone.records }}
{%- endif %}
{%- endfor %}
{%- endif %}
knot_service:
service.running:
- name: {{ server.service }}
Expand Down

0 comments on commit 48fa338

Please sign in to comment.