Replace cron.d templates with cron_d resources
authorTom Hughes <tom@compton.nu>
Sun, 19 Jul 2020 18:29:04 +0000 (19:29 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 19 Jul 2020 18:29:04 +0000 (19:29 +0100)
cookbooks/nginx/recipes/default.rb
cookbooks/nginx/templates/nginx-old-cache-cleanup.cron.erb [deleted file]
cookbooks/piwik/recipes/default.rb
cookbooks/piwik/templates/default/cron.erb [deleted file]
cookbooks/tilelog/recipes/default.rb
cookbooks/tilelog/templates/default/tilelog.cron.erb [deleted file]
cookbooks/web/recipes/statistics.rb
cookbooks/web/templates/default/statistics.cron.erb [deleted file]
cookbooks/wiki/recipes/default.rb
cookbooks/wiki/templates/default/wiki-dump.erb [deleted file]

index cfd79376dab764296ce7c9e700483ec06fb1bf42..a7775c162644d1857b9940c2641f567d35d5a633 100644 (file)
@@ -68,9 +68,9 @@ template "/usr/local/bin/nginx-old-cache-cleanup" do
   mode 0o755
 end
 
   mode 0o755
 end
 
-template "/etc/cron.d/nginx-old-cache-cleanup" do
-  source "nginx-old-cache-cleanup.cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+cron_d "nginx-old-cache-cleanup" do
+  minute "15"
+  hour "23"
+  user "www-data"
+  command "/usr/bin/timeout 6h /usr/local/bin/nginx-old-cache-cleanup"
 end
 end
diff --git a/cookbooks/nginx/templates/nginx-old-cache-cleanup.cron.erb b/cookbooks/nginx/templates/nginx-old-cache-cleanup.cron.erb
deleted file mode 100644 (file)
index 9f21e45..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# Cleanup old nginx cache storage
-15 23 * * * www-data /usr/bin/timeout 6h /usr/local/bin/nginx-old-cache-cleanup
index 990e1c33e84d85a997f13239518d740e30021b61..948c03af41b00fa964131bc8af9afcde536a926e 100644 (file)
@@ -123,9 +123,8 @@ apache_site "piwik.openstreetmap.org" do
   template "apache.erb"
 end
 
   template "apache.erb"
 end
 
-template "/etc/cron.d/piwiki" do
-  source "cron.erb"
-  owner "root"
-  group "root"
-  mode "0644"
+cron_d "piwik" do
+  minute "5"
+  user "www-data"
+  command "/usr/bin/php /srv/piwik.openstreetmap.org/console core:archive --quiet --url=https://piwik.openstreetmap.org/"
 end
 end
diff --git a/cookbooks/piwik/templates/default/cron.erb b/cookbooks/piwik/templates/default/cron.erb
deleted file mode 100644 (file)
index 2637b2f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5 * * * * www-data /usr/bin/php /srv/piwik.openstreetmap.org/console core:archive --quiet --url=https://piwik.openstreetmap.org/
index 56d7870f3c6b60ad5929a71b543ce4cc6577ab62..4d3ddb512e00896edd6f535e3345d72e0c28fd7e 100644 (file)
@@ -82,11 +82,12 @@ template "/usr/local/bin/tilelog" do
             :output_dir => tilelog_output_directory
 end
 
             :output_dir => tilelog_output_directory
 end
 
-template "/etc/cron.d/tilelog" do
-  source "tilelog.cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+cron_d "tilelog" do
+  minute "17"
+  hour "22"
+  user "www-data"
+  command "/usr/local/bin/tilelog"
+  mailto "zerebubuth@gmail.com"
 end
 
 # resources related to the output of the analysis and where it
 end
 
 # resources related to the output of the analysis and where it
diff --git a/cookbooks/tilelog/templates/default/tilelog.cron.erb b/cookbooks/tilelog/templates/default/tilelog.cron.erb
deleted file mode 100644 (file)
index bd3278e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-MAILTO=zerebubuth@gmail.com
-17 22 * * * www-data /usr/local/bin/tilelog
index c2f7d9b147ea8fa13ee8590bf3d01f509dc6685a..f725e108b5e36b35035884445a2eee07997543b1 100644 (file)
@@ -30,9 +30,9 @@ template "/usr/local/bin/statistics" do
   variables :ruby => ruby, :directory => rails_directory
 end
 
   variables :ruby => ruby, :directory => rails_directory
 end
 
-template "/etc/cron.d/statistics" do
-  source "statistics.cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+cron_d "statistics" do
+  minute "0"
+  hour "0"
+  user "rails"
+  command "/usr/local/bin/statistics"
 end
 end
diff --git a/cookbooks/web/templates/default/statistics.cron.erb b/cookbooks/web/templates/default/statistics.cron.erb
deleted file mode 100644 (file)
index 900856c..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-0 0 * * * rails /usr/local/bin/statistics
index 7e9569098f2e573430185ab3047f35407bec7335..287a645f67c94d2aa87aaed6a4a6e87708b0edde 100644 (file)
@@ -128,10 +128,9 @@ directory "/srv/wiki.openstreetmap.org/dump" do
   mode "0775"
 end
 
   mode "0775"
 end
 
-template "/etc/cron.d/wiki-dump" do
-  owner "root"
-  group "root"
-  mode 0o644
-  source "wiki-dump.erb"
-  variables :directory => "/srv/wiki.openstreetmap.org"
+cron_d "wiki-dump" do
+  minute "0"
+  hour "2"
+  user "wiki"
+  command "cd /srv/wiki.openstreetmap.org && php w/maintenance/dumpBackup.php --full --quiet --output=gzip:dump/dump.xml.gz"
 end
 end
diff --git a/cookbooks/wiki/templates/default/wiki-dump.erb b/cookbooks/wiki/templates/default/wiki-dump.erb
deleted file mode 100644 (file)
index 8139f28..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-0 2 * * * wiki cd <%= @directory %> && php w/maintenance/dumpBackup.php --full --quiet --output=gzip:dump/dump.xml.gz