include_recipe "git"
include_recipe "apache"
+geoservers = search(:node, "roles:geodns").collect(&:name).sort
+
passwords = data_bag_item("dns", "passwords")
package %w[
make
+ parallel
+ rsync
perl
libxml-treebuilder-perl
libxml-writer-perl
owner "root"
group "git"
mode 0o750
- variables :passwords => passwords
+ variables :passwords => passwords, :geoservers => geoservers
end
execute "dns-update" do
owner "root"
group "git"
mode 0o750
- variables :passwords => passwords
+ variables :passwords => passwords, :geoservers => geoservers
end
template "/etc/cron.d/dns" do
#!/bin/sh
-export RSYNC_PASSWORD=<%= @passwords["rsync"] %>
-export PINGDOM_USERNAME=pingdom@openstreetmap.org
-export PINGDOM_PASSWORD=<%= @passwords["pingdom"] %>
-export STATUSCAKE_USERNAME=OpenStreetMap
-export STATUSCAKE_APIKEY=<%= @passwords["statuscake"] %>
+export RSYNC_PASSWORD="<%= @passwords["rsync"] %>"
+export GEODNS_SERVERS="<%= @geoservers.join(" ") %>"
+export PINGDOM_USERNAME="pingdom@openstreetmap.org"
+export PINGDOM_PASSWORD="<%= @passwords["pingdom"] %>"
+export STATUSCAKE_USERNAME="OpenStreetMap"
+export STATUSCAKE_APIKEY="<%= @passwords["statuscake"] %>"
-make --quiet --directory=/var/lib/dns --assume-new=lib/countries.xml update > /dev/null
+make --quiet --jobs --directory=/var/lib/dns --assume-new=lib/countries.xml update > /dev/null
umask 0002
-export RSYNC_PASSWORD=<%= @passwords["rsync"] %>
-export PINGDOM_USERNAME=pingdom@openstreetmap.org
-export PINGDOM_PASSWORD=<%= @passwords["pingdom"] %>
-export STATUSCAKE_USERNAME=OpenStreetMap
-export STATUSCAKE_APIKEY=<%= @passwords["statuscake"] %>
+export RSYNC_PASSWORD="<%= @passwords["rsync"] %>"
+export GEODNS_SERVERS="<%= @geoservers.join(" ") %>"
+export PINGDOM_USERNAME="pingdom@openstreetmap.org"
+export PINGDOM_PASSWORD="<%= @passwords["pingdom"] %>"
+export STATUSCAKE_USERNAME="OpenStreetMap"
+export STATUSCAKE_APIKEY="<%= @passwords["statuscake"] %>"
cd /var/lib/dns
git pull -q
-make update
+make --jobs update
not_if { ::File.exist?("/var/lib/GeoIP/GeoLite2-Country.mmdb") }
end
+directory "/etc/gdnsd/config.d" do
+ owner "nobody"
+ group "nogroup"
+ mode 0o755
+end
+
template "/etc/gdnsd/config" do
source "config.erb"
owner "root"
name "geodns"
description "Role applied to all geographic DNS servers"
+default_attributes(
+ :rsyncd => {
+ :modules => {
+ :geodns => {
+ :comment => "GeoDNS",
+ :path => "/etc/gdnsd/config.d",
+ :read_only => false,
+ :write_only => true,
+ :list => false,
+ :transfer_logging => false,
+ :hosts_allow => [
+ "193.60.236.20" # sarel
+ ]
+ }
+ }
+ }
+)
+
run_list(
+ "recipe[rsyncd]",
"recipe[geodns]"
)