Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2013 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/7108221 to your computer and use it in GitHub Desktop.
Save anonymous/7108221 to your computer and use it in GitHub Desktop.
Managing Bind with Salt
available_zones:
loc.wiked.org:
file: db.loc.wiked.org
masters: "172.23.5.13"
5.23.172.in-addr.arpa:
file: db.172.23.5
masters: "172.23.5.13"
{% from "bind/map.jinja" import map with context %}
bind_config:
file:
- managed
- template: jinja
- name: {{ map.config }}
- source: {{ salt['pillar.get']('bind:config:tmpl', 'salt://bind/files/named.conf') }}
- user: {{ salt['pillar.get']('bind:config:user', 'root') }}
- group: {{ salt['pillar.get']('bind:config:group', 'bind') }}
- mode: {{ salt['pillar.get']('bind:config:mode', '640') }}
- require:
- pkg: bind
- watch_in:
- service: bind
- context:
ipv6: true
ipv6_listen: "::1"
/etc/bind/named.conf.local:
file:
- managed
- name: /etc/bind/named.conf.local
- source: 'salt://bind/files/named.conf.local'
- template: jinja
- user: 'root'
- group: 'bind'
- mode: '644'
- require:
- pkg: bind
/var/log/bind9:
file.directory:
- user: root
- group: bind
- mode: 775
- makedirs: True
{% for key,args in salt['pillar.get']('bind:zones', {}).iteritems() -%}
{%- set file = salt['pillar.get']("available_zones:" + key + ":file") %}
{% if args['type'] == "master" -%}
/var/cache/bind/zones/{{ file }}:
file:
- managed
- name: /var/cache/bind/zones/{{ file }}
- source: 'salt://bind/zones/{{ file }}'
- user: 'root'
- group: 'bind'
- mode: '644'
- watch_in:
- service: bind
{% endif %}
{% endfor %}
bind:
config:
user: root
group: bind
mode: 644
zones:
loc.wiked.org:
type: master
5.23.172.in-addr.arpa:
type: master
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "." {
type hint;
file "/etc/bind/db.root";
};
// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
{% for key,args in salt['pillar.get']('bind:zones', {}).iteritems() -%}
{%- set file = salt['pillar.get']("available_zones:" + key + ":file") %}
{%- set masters = salt['pillar.get']("available:" + key + ":masters") %}
zone "{{ key }}" {
type {{ args['type'] }};
file "zones/{{ file }}";
{% if args['type'] == "master" -%}
notify yes;
{% else -%}
masters { {{ masters }} };
{%- endif %}
};
{% endfor %}
logging {
channel "querylog" { file "/var/log/bind9/query.log"; print-time yes; };
category queries { querylog; };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment