mirror of
https://github.com/saltstack-formulas/bind-formula.git
synced 2025-04-17 02:00:23 +00:00
Add support for views.
This commit is contained in:
parent
f3ca2c660b
commit
2cef37f747
5 changed files with 75 additions and 4 deletions
|
@ -37,3 +37,8 @@ Example Pillar
|
||||||
user: root
|
user: root
|
||||||
group: named
|
group: named
|
||||||
mode: 640
|
mode: 640
|
||||||
|
|
||||||
|
Notes
|
||||||
|
=====
|
||||||
|
|
||||||
|
* When using views all zones must be configured in views!
|
||||||
|
|
|
@ -155,3 +155,32 @@ signed-{{file}}:
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{%- for view, view_data in salt['pillar.get']('bind:configured_views', {}).iteritems() %}
|
||||||
|
{% for key,args in view_data.get('configured_zones', {}).iteritems() -%}
|
||||||
|
{%- set file = salt['pillar.get']("bind:available_zones:" + key + ":file") %}
|
||||||
|
{% if args['type'] == "master" -%}
|
||||||
|
zones-{{ file }}:
|
||||||
|
file.managed:
|
||||||
|
- name: {{ map.named_directory }}/{{ file }}
|
||||||
|
- source: 'salt://bind/zones/{{ file }}'
|
||||||
|
- user: {{ salt['pillar.get']('bind:config:user', map.user) }}
|
||||||
|
- group: {{ salt['pillar.get']('bind:config:group', map.group) }}
|
||||||
|
- mode: {{ salt['pillar.get']('bind:config:mode', '644') }}
|
||||||
|
- watch_in:
|
||||||
|
- service: bind
|
||||||
|
- require:
|
||||||
|
- file: {{ map.named_directory }}
|
||||||
|
|
||||||
|
{% if args['dnssec'] is defined and args['dnssec'] -%}
|
||||||
|
signed-{{file}}:
|
||||||
|
cmd.run:
|
||||||
|
- cwd: {{ map.named_directory }}
|
||||||
|
- name: zonesigner -zone {{ key }} {{ file }}
|
||||||
|
- prereq:
|
||||||
|
- file: zones-{{ file }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
|
|
@ -9,4 +9,3 @@
|
||||||
include "/etc/bind/named.conf.key";
|
include "/etc/bind/named.conf.key";
|
||||||
include "/etc/bind/named.conf.options";
|
include "/etc/bind/named.conf.options";
|
||||||
include "/etc/bind/named.conf.local";
|
include "/etc/bind/named.conf.local";
|
||||||
include "/etc/bind/named.conf.default-zones";
|
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
// organization
|
// organization
|
||||||
//include "/etc/bind/zones.rfc1918";
|
//include "/etc/bind/zones.rfc1918";
|
||||||
|
|
||||||
{% for key,args in salt['pillar.get']('bind:configured_zones', {}).iteritems() -%}
|
{%- macro zone(key, args, file, masters) %}
|
||||||
{%- set file = salt['pillar.get']("bind:available_zones:" + key + ":file") %}
|
|
||||||
{%- set masters = salt['pillar.get']("bind:available_zones:" + key + ":masters") %}
|
|
||||||
zone "{{ key }}" {
|
zone "{{ key }}" {
|
||||||
type {{ args['type'] }};
|
type {{ args['type'] }};
|
||||||
{% if args['dnssec'] is defined and args['dnssec'] -%}
|
{% if args['dnssec'] is defined and args['dnssec'] -%}
|
||||||
|
@ -31,8 +29,39 @@ zone "{{ key }}" {
|
||||||
masters { {{ masters }} };
|
masters { {{ masters }} };
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
};
|
};
|
||||||
|
{%- endmacro %}
|
||||||
|
|
||||||
|
{%- if not pillar.bind.configured_views is defined %}
|
||||||
|
include "/etc/bind/named.conf.default-zones";
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{% for key,args in salt['pillar.get']('bind:configured_zones', {}).iteritems() -%}
|
||||||
|
{%- set file = salt['pillar.get']("bind:available_zones:" + key + ":file") %}
|
||||||
|
{%- set masters = salt['pillar.get']("bind:available_zones:" + key + ":masters") %}
|
||||||
|
{{ zone(key, args, file, masters) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for view, view_data in salt['pillar.get']('bind:configured_views', {}).iteritems() %}
|
||||||
|
|
||||||
|
view {{ view }}{
|
||||||
|
{%- if view == 'default' %}
|
||||||
|
include "/etc/bind/named.conf.default-zones";
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
match-clients{
|
||||||
|
{%- for acl in view_data.get('match_clients', {}) %}
|
||||||
|
{{ acl }};
|
||||||
|
{%- endfor %}
|
||||||
|
};
|
||||||
|
|
||||||
|
{% for key,args in view_data.get('configured_zones', {}).iteritems() -%}
|
||||||
|
{%- set file = salt['pillar.get']("bind:available_zones:" + key + ":file") %}
|
||||||
|
{%- set masters = salt['pillar.get']("bind:available_zones:" + key + ":masters") %}
|
||||||
|
{{ zone(key, args, file, masters) }}
|
||||||
|
{%- endfor %}
|
||||||
|
};
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
logging {
|
logging {
|
||||||
channel "querylog" { file "{{ map.log_dir }}/query.log"; print-time yes; };
|
channel "querylog" { file "{{ map.log_dir }}/query.log"; print-time yes; };
|
||||||
category queries { querylog; };
|
category queries { querylog; };
|
||||||
|
|
|
@ -29,6 +29,15 @@ bind:
|
||||||
type: master
|
type: master
|
||||||
allow-update: "key core_dhcp"
|
allow-update: "key core_dhcp"
|
||||||
notify: True
|
notify: True
|
||||||
|
configured_views:
|
||||||
|
myview1:
|
||||||
|
match_clients:
|
||||||
|
- client1
|
||||||
|
- client2
|
||||||
|
configured_zones:
|
||||||
|
my.zone:
|
||||||
|
type: master
|
||||||
|
notify: False
|
||||||
|
|
||||||
bind:
|
bind:
|
||||||
available_zones:
|
available_zones:
|
||||||
|
|
Loading…
Add table
Reference in a new issue