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.
 
  21 include_recipe "apache"
 
  23 geoservers = search(:node, "roles:geodns").collect(&:name).sort
 
  25 passwords = data_bag_item("dns", "passwords")
 
  32   libxml-treebuilder-perl
 
  40 remote_file "/usr/local/bin/dnscontrol" do
 
  42   source "https://github.com/StackExchange/dnscontrol/releases/download/v2.11/dnscontrol-Linux"
 
  48 directory "/srv/dns.openstreetmap.org" do
 
  54 remote_directory "/srv/dns.openstreetmap.org/html" do
 
  66 Dir.glob("/var/lib/dns/json/*.json").each do |kmlfile|
 
  67   zone = File.basename(kmlfile, ".json")
 
  69   template "/srv/dns.openstreetmap.org/html/#{zone}.html" do
 
  70     source "zone.html.erb"
 
  74     variables :zone => zone
 
  80 template "/srv/dns.openstreetmap.org/html/index.html" do
 
  81   source "index.html.erb"
 
  85   variables :zones => zones
 
  88 ssl_certificate "dns.openstreetmap.org" do
 
  89   domains ["dns.openstreetmap.org", "dns.osm.org"]
 
  90   notifies :reload, "service[apache2]"
 
  93 apache_site "dns.openstreetmap.org" do
 
  95   directory "/srv/dns.openstreetmap.org"
 
  96   variables :aliases => ["dns.osm.org"]
 
  99 template "/usr/local/bin/dns-update" do
 
 100   source "dns-update.erb"
 
 104   variables :passwords => passwords, :geoservers => geoservers
 
 107 execute "dns-update" do
 
 109   command "/usr/local/bin/dns-update"
 
 114 directory "/var/lib/dns" do
 
 118   notifies :run, "execute[dns-update]"
 
 121 template "/var/lib/dns/creds.json" do
 
 122   source "creds.json.erb"
 
 126   variables :passwords => passwords
 
 129 cookbook_file "#{node[:dns][:repository]}/hooks/post-receive" do
 
 130   source "post-receive"
 
 136 template "/usr/local/bin/dns-check" do
 
 137   source "dns-check.erb"
 
 141   variables :passwords => passwords, :geoservers => geoservers
 
 144 template "/etc/cron.d/dns" do