Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

named-checkconf, named-checkzone and rndc reload for dynamic zones #125

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions bind/config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ bind_local_config:
- file: {{ map.chroot_dir }}{{ map.log_dir }}/query.log
- watch_in:
- service: bind
- cmd: bind_checknamed_conf

{% if grains['os_family'] not in ['Arch', 'FreeBSD'] %}
bind_default_config:
Expand All @@ -113,6 +114,7 @@ bind_default_config:
map: {{ map }}
- watch_in:
- service: bind_restart
- cmd: bind_checknamed_conf
{% endif %}

{%- if salt['pillar.get']('bind:config:use_extensive_logging', False) %}
Expand All @@ -130,6 +132,7 @@ bind_logging_config:
- pkg: bind
- watch_in:
- service: bind
- cmd: bind_checknamed_conf
{%- endif %}

{% if grains['os_family'] == 'Debian' %}
Expand All @@ -145,6 +148,7 @@ bind_key_config:
- pkg: bind
- watch_in:
- service: bind
- cmd: bind_checknamed_conf

bind_options_config:
file.managed:
Expand All @@ -162,6 +166,7 @@ bind_options_config:
- pkg: bind
- watch_in:
- service: bind
- cmd: bind_checknamed_conf

bind_default_zones:
file.managed:
Expand All @@ -175,6 +180,13 @@ bind_default_zones:
- pkg: bind
- watch_in:
- service: bind
- cmd: bind_checknamed_conf

bind_checknamed_conf:
cmd.run:
- name: named-checkconf {{ map.config }}
- watch_in:
- service: bind

/etc/logrotate.d/{{ map.service }}:
file.managed:
Expand Down Expand Up @@ -216,11 +228,14 @@ bind_rndc_client_config:
{%- if salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse') %}
{%- do generate_reverse(zone_records, salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse:net'), salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse:for_zones'), salt['pillar.get']('bind:available_zones', {})) %}
{%- endif %}
{%- set dynamic_zone = zone_data.update_policy if 'update_policy' in zone_data else false %}

{# If we define RRs in pillar, we use the internal template to generate the zone file
otherwise, we fallback to the old behaviour and use the declared file
#}
{%- set zone_source = 'salt://bind/files/zone.jinja' if zone_records != {} else 'salt://' ~ map.zones_source_dir ~ '/' ~ file %}
{%- set serial_auto = salt['pillar.get']('bind:available_zones:' + zone + ':soa:serial', '') == 'auto' %}

{% if file and zone_data['type'] == 'master' -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting from here, a endif tag appears to be missing.

zones{{ dash_view }}-{{ zone }}{{ '.include' if serial_auto else ''}}:
file.managed:
Expand All @@ -244,6 +259,11 @@ zones{{ dash_view }}-{{ zone }}{{ '.include' if serial_auto else ''}}:
{% if map.get('zones_directory') %}
- file: bind_zones_directory
{% endif %}
- watch_in:
- cmd: checkzones{{ dash_view }}-{{ zone }}
{% if dynamic_zone %}
- cmd: freeze-reload-thaw{{ dash_view }}-{{ zone }}
{% endif %}

{% if serial_auto %}
zones{{ dash_view }}-{{ zone }}:
Expand All @@ -270,11 +290,16 @@ zones{{ dash_view }}-{{ zone }}:
- mode: {{ salt['pillar.get']('bind:config:mode', '644') }}
- watch_in:
- service: bind
- cmd: checkzones{{ dash_view }}-{{ zone }}
{% if dynamic_zone %}
- cmd: freeze-reload-thaw{{ dash_view }}-{{ zone }}
{% endif %}
- require:
- file: named_directory
{% if map.get('zones_directory') %}
- file: bind_zones_directory
{% endif %}

{% endif %}
{% if zone_data['dnssec'] is defined and zone_data['dnssec'] -%}
signed{{ dash_view }}-{{ zone }}:
Expand All @@ -283,7 +308,11 @@ signed{{ dash_view }}-{{ zone }}:
- name: zonesigner -zone {{ zone }} {{ file }}
- prereq:
- file: zones{{ dash_view }}-{{ zone }}
{% endif %}
- watch_in:
- cmd: checkzones{{ dash_view }}-{{ zone }}
{% if dynamic_zone %}
- cmd: freeze-reload-thaw{{ dash_view }}-{{ zone }}
{% endif %}
{% endif %}

{% if zone_data['auto-dnssec'] is defined -%}
Expand All @@ -295,7 +324,12 @@ zsk-{{ zone }}:
- unless: "grep {{ key_flags.zsk }} {{ key_directory }}/K{{zone}}.+{{ key_algorithm_field }}+*.key"
- require:
- file: bind_key_directory

- watch_in:
- cmd: checkzones{{ dash_view }}-{{ zone }}
{% if dynamic_zone %}
- cmd: freeze-reload-thaw{{ dash_view }}-{{ zone }}
{% endif %}

ksk-{{ zone }}:
cmd.run:
- cwd: {{ key_directory }}
Expand All @@ -304,6 +338,26 @@ ksk-{{ zone }}:
- unless: "grep {{ key_flags.ksk }} {{ key_directory }}/K{{zone}}.+{{ key_algorithm_field }}+*.key"
- require:
- file: bind_key_directory
- watch_in:
- cmd: checkzones{{ dash_view }}-{{ zone }}
{% if dynamic_zone %}
- cmd: freeze-reload-thaw{{ dash_view }}-{{ zone }}
{% endif %}
{% endif %}

checkzones{{ dash_view }}-{{ zone }}:
cmd.run:
- name: named-checkzone {{ zone }} {{ zones_directory }}/{{ file }}
- watch_in:
- service: bind

{% if dynamic_zone %}
# Only allowed on dynamic zones (= with update_policy)
freeze-reload-thaw{{ dash_view }}-{{ zone }}:
cmd.run:
- name: rndc freeze {{ zone }} && rndc reload {{ zone }} && rndc thaw {{ zone }}
- require_in: # execute *before* bind reload.
- service: bind
{% endif %}

{% endfor %}
Expand Down