]> git.openstreetmap.org Git - chef.git/blob - cookbooks/geodns/recipes/default.rb
Update formatting of header comments
[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 package %w[
21   geoipupdate
22   gdnsd
23 ]
24
25 execute "geoipdate" do
26   command "geoipupdate"
27   user "root"
28   group "root"
29   not_if { ::File.exist?("/var/lib/GeoIP/GeoLite2-Country.mmdb") }
30 end
31
32 directory "/etc/gdnsd/config.d" do
33   owner "nobody"
34   group "nogroup"
35   mode 0o755
36 end
37
38 template "/etc/gdnsd/config" do
39   source "config.erb"
40   owner "root"
41   group "root"
42   mode 0o644
43   notifies :restart, "service[gdnsd]"
44 end
45
46 template "/etc/gdnsd/zones/geo.openstreetmap.org" do
47   source "geo.erb"
48   owner "root"
49   group "root"
50   mode 0o644
51   notifies :restart, "service[gdnsd]"
52 end
53
54 service "gdnsd" do
55   action [:enable, :start]
56   supports :status => true, :restart => true, :reload => true
57 end
58
59 systemd_service "gdnsd-reload" do
60   description "Reload gdnsd configuration"
61   type "simple"
62   user "root"
63   exec_start "/bin/systemctl reload-or-restart gdnsd"
64   standard_output "null"
65   private_tmp true
66   private_devices true
67   protect_system "full"
68   protect_home true
69   no_new_privileges true
70 end
71
72 systemd_path "gdnsd-reload" do
73   description "Reload gdnsd configuration"
74   path_changed "/etc/gdnsd/config.d"
75 end
76
77 service "gdnsd-reload.path" do
78   action [:enable, :start]
79   subscribes :restart, "systemd_path[gdnsd-reload]"
80 end
81
82 firewall_rule "accept-dns-udp" do
83   action :accept
84   source "net"
85   dest "fw"
86   proto "udp"
87   dest_ports "domain"
88 end
89
90 firewall_rule "accept-dns-tcp" do
91   action :accept
92   source "net"
93   dest "fw"
94   proto "tcp:syn"
95   dest_ports "domain"
96 end