blob: b7eb88fc9bb24df79eeb64acc7f9e9b662647d62 [file] [log] [blame]
Ales Komarekfbfa1682014-09-22 11:31:14 +02001{%- from "bind/map.jinja" import server with context %}
2{%- if server.enabled %}
Ales Komarek882ac7b2014-07-14 10:47:56 +02003
4bind_packages:
5 pkg.installed:
Ales Komarek2eef80c2014-09-22 12:26:55 +02006 - pkgs: {{ server.pkgs }}
Ales Komarek882ac7b2014-07-14 10:47:56 +02007
8named_directory:
9 file.directory:
Ales Komarekfbfa1682014-09-22 11:31:14 +020010 - name: {{ server.named_dir }}
11 - user: {{ server.user }}
12 - group: {{ server.group }}
13 - mode: 775
14 - makedirs: True
15 - require:
Ales Komarek4caeea92014-09-22 12:32:16 +020016 - pkg: bind_packages
Ales Komarek882ac7b2014-07-14 10:47:56 +020017
Ales Komarekfbfa1682014-09-22 11:31:14 +020018{%- if grains.os_family == 'RedHat' %}
19
Ales Komarek882ac7b2014-07-14 10:47:56 +020020bind_config:
21 file.managed:
Ales Komarekfbfa1682014-09-22 11:31:14 +020022 - name: {{ server.config }}
23 - source: 'salt://bind/files/named.conf.RedHat'
24 - template: jinja
25 - user: {{ server.user }}
26 - group: {{ server.group }}
27 - mode: 640
28 - require:
29 - pkg: bind_packages
30 - watch_in:
31 - service: bind_service
Ales Komarek882ac7b2014-07-14 10:47:56 +020032
33bind_local_config:
34 file.managed:
Ales Komarek99658ee2014-09-22 12:27:56 +020035 - name: {{ server.local_config }}
Ales Komarek4caeea92014-09-22 12:32:16 +020036 - source: 'salt://bind/files/named.conf.local'
Ales Komarek882ac7b2014-07-14 10:47:56 +020037 - template: jinja
Ales Komarekfbfa1682014-09-22 11:31:14 +020038 - user: {{ server.user }}
39 - group: {{ server.group }}
40 - mode: 644
Ales Komarek882ac7b2014-07-14 10:47:56 +020041 - require:
Ales Komarekfbfa1682014-09-22 11:31:14 +020042 - pkg: bind_packages
Ales Komarek882ac7b2014-07-14 10:47:56 +020043 - watch_in:
Ales Komarekfbfa1682014-09-22 11:31:14 +020044 - service: bind_service
Ales Komarek882ac7b2014-07-14 10:47:56 +020045
Ales Komarekfbfa1682014-09-22 11:31:14 +020046{%- endif %}
47
48{%- if grains['os_family'] == 'Debian' %}
49
Ales Komarek882ac7b2014-07-14 10:47:56 +020050bind_config:
Ales Komarekfbfa1682014-09-22 11:31:14 +020051 file.managed:
Ales Komarek99658ee2014-09-22 12:27:56 +020052 - name: {{ server.config }}
Ales Komarek4caeea92014-09-22 12:32:16 +020053 - source: 'salt://bind/files/named.conf.Debian'
Ales Komarekfbfa1682014-09-22 11:31:14 +020054 - template: jinja
55 - user: {{ server.user }}
56 - group: {{ server.group }}
57 - mode: 644
58 - require:
59 - pkg: bind_packages
60 - watch_in:
61 - service: bind_service
Ales Komarek882ac7b2014-07-14 10:47:56 +020062
63bind_local_config:
Ales Komarekfbfa1682014-09-22 11:31:14 +020064 file.managed:
Ales Komarek99658ee2014-09-22 12:27:56 +020065 - name: {{ server.local_config }}
Ales Komarek4caeea92014-09-22 12:32:16 +020066 - source: 'salt://bind/files/named.conf.local'
Ales Komarekfbfa1682014-09-22 11:31:14 +020067 - template: jinja
68 - user: {{ server.user }}
69 - group: {{ server.group }}
70 - mode: 644
71 - require:
72 - pkg: bind_packages
73 - watch_in:
74 - service: bind_service
Ales Komarek882ac7b2014-07-14 10:47:56 +020075
76bind_options_config:
Ales Komarekfbfa1682014-09-22 11:31:14 +020077 file.managed:
Ales Komarek99658ee2014-09-22 12:27:56 +020078 - name: {{ server.options_config }}
Ales Komarek4caeea92014-09-22 12:32:16 +020079 - source: 'salt://bind/files/named.conf.options'
Ales Komarekfbfa1682014-09-22 11:31:14 +020080 - template: jinja
81 - user: {{ server.user }}
82 - group: {{ server.group }}
83 - mode: 644
84 - require:
85 - pkg: bind_packages
86 - watch_in:
87 - service: bind_service
Ales Komarek882ac7b2014-07-14 10:47:56 +020088
89bind_default_zones:
Ales Komarekfbfa1682014-09-22 11:31:14 +020090 file.managed:
Ales Komarek99658ee2014-09-22 12:27:56 +020091 - name: {{ server.default_zones_config }}
Ales Komarek4caeea92014-09-22 12:32:16 +020092 - source: 'salt://bind/files/named.conf.default-zones'
Ales Komarekfbfa1682014-09-22 11:31:14 +020093 - template: jinja
94 - user: {{ server.user }}
95 - group: {{ server.group }}
96 - mode: 644
97 - require:
98 - pkg: bind_packages
99 - watch_in:
100 - service: bind_service
Ales Komarek882ac7b2014-07-14 10:47:56 +0200101
102/var/log/bind9:
Ales Komarekfbfa1682014-09-22 11:31:14 +0200103 file.directory:
104 - user: {{ server.user }}
105 - group: {{ server.group }}
106 - mode: 775
107 - template: jinja
Ales Komarek882ac7b2014-07-14 10:47:56 +0200108
Ales Komarek79e50802014-09-22 12:40:50 +0200109/var/log/bind9/query.log:
110 file.managed:
111 - user: {{ server.user }}
112 - group: {{ server.group }}
113
Ales Komarek882ac7b2014-07-14 10:47:56 +0200114/etc/logrotate.d/bind9:
Ales Komarekfbfa1682014-09-22 11:31:14 +0200115 file.managed:
116 - source: salt://bind/files/logrotate
117 - user: root
118 - group: root
119
Ales Komarek882ac7b2014-07-14 10:47:56 +0200120{%- endif %}
121
122bind_service:
123 service.running:
Ales Komarekfbfa1682014-09-22 11:31:14 +0200124 - name: {{ server.service }}
125 - enable: true
126 - reload: true
127 - require:
128 - pkg: bind_packages
129
Ales Komarek5b8ee922014-09-22 12:28:51 +0200130setup_rndc:
131 cmd.run:
132 - name: /usr/sbin/rndc-confgen -r /dev/urandom -a -c {{ server.rndc_key }}
Ales Komarekc1ed1f32014-09-22 12:37:22 +0200133 - unless: test -e {{ server.rndc_key }}
Ales Komarek5b8ee922014-09-22 12:28:51 +0200134 - require:
135 - pkg: bind_packages
136
137{{ server.rndc_key }}:
138 file.managed:
139 - user: root
140 - mode: 0640
141 - require:
142 - cmd: setup_rndc
143
Ales Komarekfbfa1682014-09-22 11:31:14 +0200144{%- endif %}