]> git.openstreetmap.org Git - chef.git/blob - cookbooks/geodns/recipes/default.rb
Configure NS records for geodns servers automatically
[chef.git] / cookbooks / geodns / recipes / default.rb
1 #
2 # Cookbook:: geodns
3 # Recipe:: default
4 #
5 # Copyright:: 2011, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 include_recipe "geoipupdate"
21
22 servers = search(:node, "roles:geodns").collect(&:name).sort
23
24 package %w[
25   gdnsd
26 ]
27
28 directory "/etc/gdnsd/config.d" do
29   owner "nobody"
30   group "nogroup"
31   mode "755"
32 end
33
34 %w[nominatim].each do |zone|
35   %w[map resource weighted].each do |type|
36     template "/etc/gdnsd/config.d/#{zone}.#{type}" do
37       action :create_if_missing
38       source "zone.#{type}.erb"
39       owner "nobody"
40       group "nogroup"
41       mode "644"
42       variables :zone => zone
43     end
44   end
45 end
46
47 template "/etc/gdnsd/config" do
48   source "config.erb"
49   owner "root"
50   group "root"
51   mode "644"
52   notifies :restart, "service[gdnsd]"
53 end
54
55 template "/etc/gdnsd/zones/geo.openstreetmap.org" do
56   source "geo.erb"
57   owner "root"
58   group "root"
59   mode "644"
60   variables :servers => servers
61   notifies :restart, "service[gdnsd]"
62 end
63
64 service "gdnsd" do
65   action [:enable, :start]
66   supports :status => true, :restart => true, :reload => true
67 end
68
69 systemd_service "gdnsd-reload" do
70   description "Reload gdnsd configuration"
71   type "simple"
72   user "root"
73   exec_start "/bin/systemctl reload-or-restart gdnsd"
74   standard_output "null"
75   private_tmp true
76   private_devices true
77   protect_system "full"
78   protect_home true
79   no_new_privileges true
80 end
81
82 systemd_path "gdnsd-reload" do
83   description "Reload gdnsd configuration"
84   path_changed "/etc/gdnsd/config.d"
85 end
86
87 service "gdnsd-reload.path" do
88   action [:enable, :start]
89   subscribes :restart, "systemd_path[gdnsd-reload]"
90 end
91
92 firewall_rule "accept-dns-udp" do
93   action :accept
94   source "net"
95   dest "fw"
96   proto "udp"
97   dest_ports "domain"
98 end
99
100 firewall_rule "accept-dns-tcp" do
101   action :accept
102   source "net"
103   dest "fw"
104   proto "tcp:syn"
105   dest_ports "domain"
106 end