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 cache_dir = Chef::Config[:file_cache_path]
44 dnscontrol_version = "3.19.0"
46 remote_file "#{cache_dir}/dnscontrol_amd64.deb" do
47 source "https://github.com/StackExchange/dnscontrol/releases/download/v#{dnscontrol_version}/dnscontrol_#{dnscontrol_version}_amd64.deb"
54 dpkg_package "dnscontrol" do
56 source "#{cache_dir}/dnscontrol_amd64.deb"
57 subscribes :install, "remote_file[#{cache_dir}/dnscontrol_amd64.deb]"
60 file "/usr/local/bin/dnscontrol" do
64 directory "/srv/dns.openstreetmap.org" do
70 remote_directory "/srv/dns.openstreetmap.org/html" do
82 Dir.glob("/var/lib/dns/json/*.json").each do |kmlfile|
83 zone = File.basename(kmlfile, ".json")
85 template "/srv/dns.openstreetmap.org/html/#{zone}.html" do
86 source "zone.html.erb"
90 variables :zone => zone
96 template "/srv/dns.openstreetmap.org/html/index.html" do
97 source "index.html.erb"
101 variables :zones => zones
104 ssl_certificate "dns.openstreetmap.org" do
105 domains ["dns.openstreetmap.org", "dns.osm.org"]
106 notifies :reload, "service[apache2]"
109 apache_site "dns.openstreetmap.org" do
110 template "apache.erb"
111 directory "/srv/dns.openstreetmap.org"
112 variables :aliases => ["dns.osm.org"]
115 template "/usr/local/bin/dns-update" do
116 source "dns-update.erb"
120 variables :passwords => passwords, :geoservers => geoservers
123 execute "dns-update" do
125 command "/usr/local/bin/dns-update"
130 directory "/var/lib/dns" do
134 notifies :run, "execute[dns-update]"
137 template "/var/lib/dns/creds.json" do
138 source "creds.json.erb"
142 variables :passwords => passwords
145 template "/var/lib/dns/include/geo.js" do
150 variables :geoservers => geoservers
151 only_if { ::Dir.exist?("/var/lib/dns/include") }
154 cookbook_file "#{node[:dns][:repository]}/hooks/post-receive" do
155 source "post-receive"
159 only_if { ::Dir.exist?("#{node[:dns][:repository]}/hooks") }
162 template "/usr/local/bin/dns-check" do
163 source "dns-check.erb"
167 variables :passwords => passwords, :geoservers => geoservers
173 command "/usr/local/bin/dns-check"
174 mailto "admins@openstreetmap.org"