-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathetc_named.conf.j2
210 lines (195 loc) · 6.74 KB
/
etc_named.conf.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//
// named.conf
//
{{ ansible_managed | comment('c') }}
//
{% for acl in bind_acls %}
acl "{{ acl.name }}" {
{% for match in acl.match_list %}
{{ match }};
{% endfor %}
};
{% endfor %}
options {
{% for port in bind_listen_ipv4_port %}
listen-on port {{ port }} { {{ bind_listen_ipv4|join('; ') }}; };
{% endfor %}
{% for port in bind_listen_ipv6_port %}
listen-on-v6 port {{ port }} { {{ bind_listen_ipv6|join('; ') }}; };
{% endfor %}
directory "{{ bind_dir }}";
dump-file "{{ bind_dir }}/data/cache_dump.db";
statistics-file "{{ bind_dir }}/data/named_stats.txt";
memstatistics-file "{{ bind_dir }}/data/named_mem_stats.txt";
allow-query { {{ bind_allow_query|join('; ') }}; };
{% if bind_acls|length != 0 %}
allow-transfer { {% for acl in bind_acls %}"{{ acl.name }}"; {% endfor %}};
{% endif %}
{% if bind_check_names is defined %}
check-names {{ bind_check_names }};
{% endif %}
recursion {% if bind_recursion %}yes{% else %}no{% endif %};
{% if bind_recursion %}allow-recursion { {{ bind_allow_recursion|join('; ') }}; };
{% endif %}
{% if bind_forwarders|length > 0 %}forwarders { {{ bind_forwarders|join('; ') }}; };{% endif %}
{% if bind_forward_only %}forward only;{% endif %}
rrset-order { order {{ bind_rrset_order }}; };
{% if bind_dnssec_enable %} dnssec-enable {{ bind_dnssec_enable }};{% endif %}
dnssec-validation {{ bind_dnssec_validation }};
/* Path to ISC DLV key */
bindkeys-file "{{ bind_bindkeys_file }}";
managed-keys-directory "{{ bind_dir }}/dynamic";
pid-file "{{ bind_pid_file }}";
session-keyfile "{{ bind_session_keyfile }}";
{% if bind_query_log is defined %}
querylog yes;
{% endif %}
{% if bind_dns64 %}
dns64 64:ff9b::/96 {
clients { {{ bind_dns64_clients|join('; ') }}; };
};
{% endif %}
};
{% if bind_statistics_channels %}
statistics-channels {
inet {{ bind_statistics_host }} port {{ bind_statistics_port }} allow { {{ bind_statistics_allow|join('; ') }}; };
};
{% endif %}
logging {
channel default_debug {
file "{{ bind_log }}";
severity dynamic;
print-time yes;
};
{% if bind_query_log is defined %}
channel querylog {
{% if bind_query_log.file is defined %}
file "{{ bind_query_log.file }}" versions {{ bind_query_log.versions }} size {{ bind_query_log.size }};
{% else %}
file "{{ bind_query_log }}" versions 600 size 20m;
{% endif %}
severity dynamic;
print-time yes;
};
category queries { querylog; };
{% endif %}
{% if bind_other_logs is defined %}
{% for log in bind_other_logs %}
channel {{ log.name }} {
file "{{ log.file }}" versions {{ log.versions }} size {{ log.size }};
severity dynamic;
print-time yes;
};
category "{{ log.name }}" { "{{ log.name }}"; };
{% endfor %}
{% endif %}
};
{% for file in bind_default_zone_files %}
include "{{ file }}";
{% endfor %}
{% for file in bind_extra_include_files %}
include "{{ file }}";
{% endfor %}
{% if bind_zones is defined %}
{% for bind_zone in bind_zones %}
{% if bind_zone.create_forward_zones is not defined or bind_zone.create_forward_zones %}
{# Start: set zone type #}
{% set _all_addresses = ansible_all_ipv4_addresses | union(ansible_all_ipv6_addresses) %}
{% if bind_zone.type is defined and bind_zone.type == 'primary' %}
{% set _type = 'primary' %}
{% elif bind_zone.type is defined and bind_zone.type == 'secondary' %}
{% set _type = 'secondary' %}
{% elif bind_zone.type is defined and bind_zone.type == 'forward' %}
{% set _type = 'forward' %}
{% elif bind_zone.type is not defined and bind_zone.primaries is defined and (_all_addresses|intersect(bind_zone.primaries)|length > 0) %}
{% set _type = 'primary' %}
{% elif bind_zone.type is not defined and bind_zone.primaries is defined and not (_all_addresses|intersect(bind_zone.primaries)|length > 0) %}
{% set _type = 'secondary' %}
{% elif bind_zone.type is not defined and bind_zone.forwarders is defined %}
{% set _type = 'forward' %}
{% endif %}
{# End: set zone type #}
zone "{{ bind_zone.name }}" IN {
{% if _type == 'primary' %}
type master;
file "{{ bind_zone_dir }}/{{ bind_zone.name }}";
notify yes;
{% if bind_zone.also_notify is defined %}
also-notify { {{ bind_zone.also_notify|join('; ') }}; };
{% endif %}
{% if bind_zone.allow_update is defined %}
allow-update { {{ bind_zone.allow_update|join('; ') }}; };
{% else %}
allow-update { none; };
{% endif %}
{% elif _type == 'secondary' %}
type slave;
masters { {{ bind_zone.primaries|join('; ') }}; };
file "{{ bind_secondary_dir }}/{{ bind_zone.name }}";
{% elif _type == 'forward' %}
type forward;
forward only;
forwarders { {{ bind_zone.forwarders|join('; ') }}; };
{% endif %}
};
{% endif %}
{% if bind_zone.networks is defined %}
{% if bind_zone.create_reverse_zones is not defined or bind_zone.create_reverse_zones %}
{% for network in bind_zone.networks %}
zone "{{ ('.'.join(network.replace(network+'.','').split('.')[::-1])) }}.in-addr.arpa" IN {
{% if _type == 'primary' %}
type master;
file "{{ bind_zone_dir }}/{{ ('.'.join(network.replace(network+'.','').split('.')[::-1])) }}.in-addr.arpa";
notify yes;
{% if bind_zone.also_notify is defined %}
also-notify { {{ bind_zone.also_notify|join('; ') }}; };
{% endif %}
{% if bind_zone.allow_update is defined %}
allow-update { {{ bind_zone.allow_update|join('; ') }}; };
{% else %}
allow-update { none; };
{% endif %}
{% elif _type == 'secondary' %}
type slave;
masters { {{ bind_zone.primaries|join('; ') }}; };
file "{{ bind_secondary_dir }}/{{ ('.'.join(network.replace(network+'.','').split('.')[::-1])) }}.in-addr.arpa";
{% elif _type == 'forward' %}
type forward;
forward only;
forwarders { {{ bind_zone.forwarders|join('; ') }}; };
{% endif %}
};
{% endfor %}
{% endif %}
{% endif %}
{% if bind_zone.ipv6_networks is defined %}
{% if bind_zone.create_reverse_zones is not defined or bind_zone.create_reverse_zones %}
{% for network in bind_zone.ipv6_networks %}
zone "{{ (network | ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):] }}" IN {
{% if _type == 'primary' %}
type master;
file "{{ bind_zone_dir }}/{{ (network | ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):-1] }}";
notify yes;
{% if bind_zone.also_notify is defined %}
also-notify { {{ bind_zone.also_notify|join('; ') }}; };
{% endif %}
{% if bind_zone.allow_update is defined %}
allow-update { {{ bind_zone.allow_update|join('; ') }}; };
{% else %}
allow-update { none; };
{% endif %}
{% elif _type == 'secondary' %}
type slave;
masters { {{ bind_zone.primaries|join('; ') }}; };
file "{{ bind_secondary_dir }}/{{ (network | ipaddr('revdns'))[-(9+(network|regex_replace('^.*/','')|int)//2):-1] }}";
{% elif _type == 'forward' %}
type forward;
forward only;
forwarders { {{ bind_zone.forwarders|join('; ') }}; };
{% endif %}
};
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}