]> git.openstreetmap.org Git - chef.git/blob - cookbooks/dns/recipes/default.rb
Update formatting of header comments
[chef.git] / cookbooks / dns / recipes / default.rb
1 #
2 # Cookbook:: dns
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 "git"
21 include_recipe "apache"
22
23 geoservers = search(:node, "roles:geodns").collect(&:name).sort
24
25 passwords = data_bag_item("dns", "passwords")
26
27 package %w[
28   make
29   parallel
30   rsync
31   perl
32   libxml-treebuilder-perl
33   libxml-writer-perl
34   libyaml-perl
35   libwww-perl
36   libjson-xs-perl
37 ]
38
39 directory "/srv/dns.openstreetmap.org" do
40   owner "root"
41   group "root"
42   mode 0o755
43 end
44
45 remote_directory "/srv/dns.openstreetmap.org/html" do
46   source "html"
47   owner "root"
48   group "root"
49   mode 0o755
50   files_owner "root"
51   files_group "root"
52   files_mode 0o644
53 end
54
55 zones = []
56
57 Dir.glob("/var/lib/dns/json/*.json").each do |kmlfile|
58   zone = File.basename(kmlfile, ".json")
59
60   template "/srv/dns.openstreetmap.org/html/#{zone}.html" do
61     source "zone.html.erb"
62     owner "root"
63     group "root"
64     mode 0o644
65     variables :zone => zone
66   end
67
68   zones.push(zone)
69 end
70
71 template "/srv/dns.openstreetmap.org/html/index.html" do
72   source "index.html.erb"
73   owner "root"
74   group "root"
75   mode 0o644
76   variables :zones => zones
77 end
78
79 ssl_certificate "dns.openstreetmap.org" do
80   domains ["dns.openstreetmap.org", "dns.osm.org"]
81   notifies :reload, "service[apache2]"
82 end
83
84 apache_site "dns.openstreetmap.org" do
85   template "apache.erb"
86   directory "/srv/dns.openstreetmap.org"
87   variables :aliases => ["dns.osm.org"]
88 end
89
90 template "/usr/local/bin/dns-update" do
91   source "dns-update.erb"
92   owner "root"
93   group "git"
94   mode 0o750
95   variables :passwords => passwords, :geoservers => geoservers
96 end
97
98 execute "dns-update" do
99   action :nothing
100   command "/usr/local/bin/dns-update"
101   user "git"
102   group "git"
103 end
104
105 directory "/var/lib/dns" do
106   owner "git"
107   group "git"
108   mode 0o2775
109   notifies :run, "execute[dns-update]"
110 end
111
112 cookbook_file "#{node[:dns][:repository]}/hooks/post-receive" do
113   source "post-receive"
114   owner "git"
115   group "git"
116   mode 0o750
117 end
118
119 template "/usr/local/bin/dns-check" do
120   source "dns-check.erb"
121   owner "root"
122   group "git"
123   mode 0o750
124   variables :passwords => passwords, :geoservers => geoservers
125 end
126
127 template "/etc/cron.d/dns" do
128   source "cron.erb"
129   owner "root"
130   group "root"
131   mode 0o644
132 end