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.20.0"
46 dnscontrol_arch = arm? ? "arm64" : "amd64"
48 remote_file "#{cache_dir}/dnscontrol-#{dnscontrol_version}.deb" do
49 source "https://github.com/StackExchange/dnscontrol/releases/download/v#{dnscontrol_version}/dnscontrol-#{dnscontrol_version}.#{dnscontrol_arch}.deb"
56 dpkg_package "dnscontrol" do
58 source "#{cache_dir}/dnscontrol-#{dnscontrol_version}.deb"
59 subscribes :install, "remote_file[#{cache_dir}/dnscontrol-#{dnscontrol_version}.deb]"
62 directory "/srv/dns.openstreetmap.org" do
68 remote_directory "/srv/dns.openstreetmap.org/html" do
80 Dir.glob("/var/lib/dns/json/*.json").each do |kmlfile|
81 zone = File.basename(kmlfile, ".json")
83 template "/srv/dns.openstreetmap.org/html/#{zone}.html" do
84 source "zone.html.erb"
88 variables :zone => zone
94 template "/srv/dns.openstreetmap.org/html/index.html" do
95 source "index.html.erb"
99 variables :zones => zones
102 ssl_certificate "dns.openstreetmap.org" do
103 domains ["dns.openstreetmap.org", "dns.osm.org"]
104 notifies :reload, "service[apache2]"
107 apache_site "dns.openstreetmap.org" do
108 template "apache.erb"
109 directory "/srv/dns.openstreetmap.org"
110 variables :aliases => ["dns.osm.org"]
113 template "/usr/local/bin/dns-update" do
114 source "dns-update.erb"
118 variables :passwords => passwords, :geoservers => geoservers
121 execute "dns-update" do
123 command "/usr/local/bin/dns-update"
128 directory "/var/lib/dns" do
132 notifies :run, "execute[dns-update]"
135 template "/var/lib/dns/creds.json" do
136 source "creds.json.erb"
140 variables :passwords => passwords
143 template "/var/lib/dns/include/geo.js" do
148 variables :geoservers => geoservers
149 only_if { ::Dir.exist?("/var/lib/dns/include") }
152 cookbook_file "#{node[:dns][:repository]}/hooks/post-receive" do
153 source "post-receive"
157 only_if { ::Dir.exist?("#{node[:dns][:repository]}/hooks") }
160 template "/usr/local/bin/dns-check" do
161 source "dns-check.erb"
165 variables :passwords => passwords, :geoservers => geoservers
171 command "/usr/local/bin/dns-check"
172 mailto "admins@openstreetmap.org"