blob: 8a778fbcd0387ba2013468b5ac739625af8546a5 [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:
16 - pkg: bind
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:
35 - name: {{ map.local_config }}
36 - source: 'salt://bind/files/redhat/named.conf.local'
37 - 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:
52 - name: {{ map.config }}
53 - source: 'salt://bind/files/debian/named.conf.Debian'
54 - 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:
65 - name: {{ map.local_config }}
66 - source: 'salt://bind/files/debian/named.conf.local'
67 - 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:
78 - name: {{ map.options_config }}
79 - source: 'salt://bind/files/debian/named.conf.options'
80 - 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:
91 - name: {{ map.default_zones_config }}
92 - source: 'salt://bind/files/debian/named.conf.default-zones'
93 - 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
109/etc/logrotate.d/bind9:
Ales Komarekfbfa1682014-09-22 11:31:14 +0200110 file.managed:
111 - source: salt://bind/files/logrotate
112 - user: root
113 - group: root
114
115setup_rndc:
116 cmd.run:
117 - name: /usr/sbin/rndc-confgen -r /dev/urandom -a -c {{ server.rndc_key }}
118 - require:
119 - pkg: bind_packages
120
121{{ server.rndc_key }}
122 file.managed:
123 - user: root
124 - mode: 0640
125 - require:
126 - cmd: setup_rndc
Ales Komarek882ac7b2014-07-14 10:47:56 +0200127
128{%- endif %}
129
130bind_service:
131 service.running:
Ales Komarekfbfa1682014-09-22 11:31:14 +0200132 - name: {{ server.service }}
133 - enable: true
134 - reload: true
135 - require:
136 - pkg: bind_packages
137
138{%- endif %}