]> git.openstreetmap.org Git - chef.git/blob - cookbooks/geodns/recipes/default.rb
Merge remote-tracking branch 'github/pull/422'
[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 package %w[
23   gdnsd
24 ]
25
26 directory "/etc/gdnsd/config.d" do
27   owner "nobody"
28   group "nogroup"
29   mode "755"
30 end
31
32 %w[tile nominatim].each do |zone|
33   %w[map resource weighted].each do |type|
34     template "/etc/gdnsd/config.d/#{zone}.#{type}" do
35       action :create_if_missing
36       source "zone.#{type}.erb"
37       owner "nobody"
38       group "nogroup"
39       mode "644"
40       variables :zone => zone
41     end
42   end
43 end
44
45 template "/etc/gdnsd/config" do
46   source "config.erb"
47   owner "root"
48   group "root"
49   mode "644"
50   notifies :restart, "service[gdnsd]"
51 end
52
53 template "/etc/gdnsd/zones/geo.openstreetmap.org" do
54   source "geo.erb"
55   owner "root"
56   group "root"
57   mode "644"
58   notifies :restart, "service[gdnsd]"
59 end
60
61 service "gdnsd" do
62   action [:enable, :start]
63   supports :status => true, :restart => true, :reload => true
64 end
65
66 systemd_service "gdnsd-reload" do
67   description "Reload gdnsd configuration"
68   type "simple"
69   user "root"
70   exec_start "/bin/systemctl reload-or-restart gdnsd"
71   standard_output "null"
72   private_tmp true
73   private_devices true
74   protect_system "full"
75   protect_home true
76   no_new_privileges true
77 end
78
79 systemd_path "gdnsd-reload" do
80   description "Reload gdnsd configuration"
81   path_changed "/etc/gdnsd/config.d"
82 end
83
84 service "gdnsd-reload.path" do
85   action [:enable, :start]
86   subscribes :restart, "systemd_path[gdnsd-reload]"
87 end
88
89 firewall_rule "accept-dns-udp" do
90   action :accept
91   source "net"
92   dest "fw"
93   proto "udp"
94   dest_ports "domain"
95 end
96
97 firewall_rule "accept-dns-tcp" do
98   action :accept
99   source "net"
100   dest "fw"
101   proto "tcp:syn"
102   dest_ports "domain"
103 end