5 # Copyright:: 2011, OpenStreetMap Foundation
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
11 # https://www.apache.org/licenses/LICENSE-2.0
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.
20 include_recipe "accounts"
21 include_recipe "apache"
24 geoservers = search(:node, "roles:geodns").collect(&:name).sort
26 passwords = data_bag_item("dns", "passwords")
36 libxml-treebuilder-perl
42 remote_file "/usr/local/bin/dnscontrol" do
44 source "https://github.com/StackExchange/dnscontrol/releases/download/v3.10.1/dnscontrol-Linux"
50 directory "/srv/dns.openstreetmap.org" do
56 remote_directory "/srv/dns.openstreetmap.org/html" do
68 Dir.glob("/var/lib/dns/json/*.json").each do |kmlfile|
69 zone = File.basename(kmlfile, ".json")
71 template "/srv/dns.openstreetmap.org/html/#{zone}.html" do
72 source "zone.html.erb"
76 variables :zone => zone
82 template "/srv/dns.openstreetmap.org/html/index.html" do
83 source "index.html.erb"
87 variables :zones => zones
90 ssl_certificate "dns.openstreetmap.org" do
91 domains ["dns.openstreetmap.org", "dns.osm.org"]
92 notifies :reload, "service[apache2]"
95 apache_site "dns.openstreetmap.org" do
97 directory "/srv/dns.openstreetmap.org"
98 variables :aliases => ["dns.osm.org"]
101 template "/usr/local/bin/dns-update" do
102 source "dns-update.erb"
106 variables :passwords => passwords, :geoservers => geoservers
109 execute "dns-update" do
111 command "/usr/local/bin/dns-update"
116 directory "/var/lib/dns" do
120 notifies :run, "execute[dns-update]"
123 template "/var/lib/dns/creds.json" do
124 source "creds.json.erb"
128 variables :passwords => passwords
131 cookbook_file "#{node[:dns][:repository]}/hooks/post-receive" do
132 source "post-receive"
136 only_if { ::Dir.exist?("#{node[:dns][:repository]}/hooks") }
139 template "/usr/local/bin/dns-check" do
140 source "dns-check.erb"
144 variables :passwords => passwords, :geoservers => geoservers
150 command "/usr/local/bin/dns-check"
151 mailto "admins@openstreetmap.org"