]> git.openstreetmap.org Git - chef.git/commitdiff
Replace cron.d templates with cron_d resources
authorTom Hughes <tom@compton.nu>
Tue, 21 Jul 2020 17:42:33 +0000 (18:42 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 21 Jul 2020 17:44:53 +0000 (18:44 +0100)
cookbooks/planet/recipes/current.rb
cookbooks/planet/recipes/default.rb
cookbooks/planet/recipes/dump.rb
cookbooks/planet/recipes/notes.rb
cookbooks/planet/recipes/replication.rb
cookbooks/planet/templates/default/old-planet-file-cleanup.cron.erb [deleted file]
cookbooks/planet/templates/default/planet-dump-mirror-cron.erb [deleted file]
cookbooks/planet/templates/default/planet-notes-dump.cron.erb [deleted file]
cookbooks/planet/templates/default/planet-update.cron.erb [deleted file]
cookbooks/planet/templates/default/replication.cron.erb [deleted file]

index 20c77b7322c8752bab271fd6c877695f7271794d..6242559eb054714cfc9e8b99efe0471465c817d2 100644 (file)
@@ -52,11 +52,11 @@ remote_file "/var/lib/planet/planet.pbf" do
   not_if { ENV["TEST_KITCHEN"] }
 end
 
-template "/etc/cron.d/planet-update" do
-  source "planet-update.cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+cron_d "planet-update" do
+  minute "17"
+  hour "1"
+  user "root"
+  command "/usr/local/bin/planet-update"
 end
 
 template "/etc/logrotate.d/planet-update" do
index b72d4d1c5434fed666563c7d5e61e8c2ae0621d7..4ea86b7ac5d7d444090b5dcd41b921a6f13f89a3 100644 (file)
@@ -26,10 +26,6 @@ package %w[
   php-cli
 ]
 
-file "/etc/cron.d/planet" do
-  action :delete
-end
-
 remote_directory "/store/planet#html" do
   path "/store/planet"
   source "html"
@@ -125,9 +121,12 @@ template "/usr/local/bin/old-planet-file-cleanup" do
   mode 0o755
 end
 
-template "/etc/cron.d/old-planet-file-cleanup" do
-  source "old-planet-file-cleanup.cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+cron_d "old-planet-file-cleanup" do
+  comment "run this on the first monday of the month at 3:44am"
+  minute "44"
+  hour "3"
+  day "1-7"
+  user "www-data"
+  command "test $(date +\%u) -eq 1 && /usr/local/bin/old-planet-file-cleanup --debug"
+  mailto "zerebubuth@gmail.com"
 end
index d873a903652b3999bc11920b1bb6e8a0c7b5a329..1d1d170bf433342ff44992346838657493b66270 100644 (file)
@@ -120,9 +120,9 @@ systemd_service "planetdump@" do
   no_new_privileges true
 end
 
-template "/etc/cron.d/planet-dump-mirror" do
-  source "planet-dump-mirror-cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+cron_d "planet-dump-mirror" do
+  minute "*/10"
+  user "www-data"
+  command "/usr/local/bin/planet-mirror-redirect-update"
+  mailto "horntail-www-data-cron@firefishy.com"
 end
index 68a548b1554a6b75219dfab41c5f8f17dde76ab4..662abe770b37b074f44f6f2626111f0da60cf66f 100644 (file)
@@ -50,9 +50,19 @@ template "/usr/local/bin/planet-notes-dump" do
   variables :password => db_passwords["planetdump"]
 end
 
-template "/etc/cron.d/planet-notes-dump" do
-  source "planet-notes-dump.cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+cron_d "planet-notes-dump" do
+  minute "0"
+  hour "3"
+  user "www-data"
+  command "/usr/local/bin/planet-notes-dump"
+  mailto "grant-smaug@firefishy.com"
+end
+
+cron_d "planet-notes-cleanup" do
+  comment "Delete Planet Notes dump files older than 8 days"
+  minute "10"
+  hour "8"
+  user "www-data"
+  command "find /store/planet/notes/20??/ -maxdepth 1 -type f -iname 'planet-notes-??????.osn*' -printf '\%T@ \%p\n' | sort -k 1nr | sed 's/^[^ ]* //' | tail -n +17 | xargs -r rm -f"
+  mailto "grant-smaug@firefishy.com"
 end
index f1be1d0d0b45fe8676d1c8b3ad37b5854b85b851..3fbfd73774de0a758f773bed794ef34d1c15bcb3 100644 (file)
@@ -200,14 +200,72 @@ link "/var/lib/replication/day/data" do
 end
 
 if node[:planet][:replication] == "enabled"
-  template "/etc/cron.d/replication" do
-    source "replication.cron.erb"
-    owner "root"
-    group "root"
-    mode 0o644
+  cron_d "users-agreed" do
+    minute "0"
+    hour "7"
+    user "planet"
+    command "/usr/local/bin/users-agreed"
+    mailto "zerebubuth@gmail.com"
+  end
+
+  cron_d "users-deleted" do
+    minute "0"
+    hour "17"
+    user "planet"
+    command "/usr/local/bin/users-deleted"
+    mailto "zerebubuth@gmail.com"
+  end
+
+  cron_d "replication-changesets" do
+    user "planet"
+    command "/usr/local/bin/replicate-changesets /etc/replication/changesets.conf"
+    mailto "zerebubuth@gmail.com"
+  end
+
+  cron_d "replication-minutely" do
+    user "planet"
+    command "/usr/local/bin/osmosis -q --replicate-apidb authFile=/etc/replication/auth.conf validateSchemaVersion=false --write-replication workingDirectory=/store/planet/replication/minute"
+    mailto "brett@bretth.com"
+    environment "LD_PRELOAD" => "/opt/flush/flush.so"
+  end
+
+  cron_d "replication-hourly" do
+    minute "2,7,12,17"
+    user "planet"
+    command "/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/hour"
+    mailto "brett@bretth.com"
+    environment "LD_PRELOAD" => "/opt/flush/flush.so"
+  end
+
+  cron_d "replication-daily" do
+    minute "5,10,15,20"
+    user "planet"
+    command "/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/day"
+    mailto "brett@bretth.com"
+    environment "LD_PRELOAD" => "/opt/flush/flush.so"
   end
 else
-  file "/etc/cron.d/replication" do
+  cron_d "users-agreed" do
+    action :delete
+  end
+
+  cron_d "users-deleted" do
+    action :delete
+  end
+
+  cron_d "replication-changesets" do
+    action :delete
+  end
+
+  cron_d "replication-minutely" do
+    action :delete
+  end
+
+  cron_d "replication-hourly" do
+    action :delete
+  end
+
+  cron_d "replication-daily" do
     action :delete
   end
 end
diff --git a/cookbooks/planet/templates/default/old-planet-file-cleanup.cron.erb b/cookbooks/planet/templates/default/old-planet-file-cleanup.cron.erb
deleted file mode 100644 (file)
index 4c880b4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-MAILTO=zerebubuth@gmail.com
-# run this on the first monday of the month at 3:44am
-44 3 1-7 * * www-data test $(date +\%u) -eq 1 && /usr/local/bin/old-planet-file-cleanup --debug
diff --git a/cookbooks/planet/templates/default/planet-dump-mirror-cron.erb b/cookbooks/planet/templates/default/planet-dump-mirror-cron.erb
deleted file mode 100644 (file)
index d635c10..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-MAILTO=horntail-www-data-cron@firefishy.com
-*/10 * * * * www-data /usr/local/bin/planet-mirror-redirect-update
diff --git a/cookbooks/planet/templates/default/planet-notes-dump.cron.erb b/cookbooks/planet/templates/default/planet-notes-dump.cron.erb
deleted file mode 100644 (file)
index 3c5709a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-MAILTO=grant-smaug@firefishy.com
-0 3 * * * www-data /usr/local/bin/planet-notes-dump
-
-#Delete Planet Notes dump files older than 8 days
-10 8 * * * www-data find /store/planet/notes/20??/ -maxdepth 1 -type f -iname 'planet-notes-??????.osn*' -printf '\%T@ \%p\n' | sort -k 1nr | sed 's/^[^ ]* //' | tail -n +17 | xargs -r rm -f
diff --git a/cookbooks/planet/templates/default/planet-update.cron.erb b/cookbooks/planet/templates/default/planet-update.cron.erb
deleted file mode 100644 (file)
index 5a9f6f7..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-17 1 * * * root /usr/local/bin/planet-update
diff --git a/cookbooks/planet/templates/default/replication.cron.erb b/cookbooks/planet/templates/default/replication.cron.erb
deleted file mode 100644 (file)
index 80d7184..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-TZ=UTC
-
-MAILTO=zerebubuth@gmail.com
-
-0 7 * * * planet /usr/local/bin/users-agreed
-0 17 * * * planet /usr/local/bin/users-deleted
-* * * * * planet /usr/local/bin/replicate-changesets /etc/replication/changesets.conf
-
-MAILTO=brett@bretth.com
-LD_PRELOAD=/opt/flush/flush.so
-
-* * * * * planet /usr/local/bin/osmosis -q --replicate-apidb authFile=/etc/replication/auth.conf validateSchemaVersion=false --write-replication workingDirectory=/store/planet/replication/minute
-2,7,12,17 * * * * planet /usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/hour
-5,10,15,20 * * * * planet /usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/day