From: Tom Hughes Date: Sun, 19 Jul 2020 18:29:04 +0000 (+0100) Subject: Replace cron.d templates with cron_d resources X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/0751a4f9434ce69a40996fbec967501fe43e4f83?ds=sidebyside Replace cron.d templates with cron_d resources --- diff --git a/cookbooks/nginx/recipes/default.rb b/cookbooks/nginx/recipes/default.rb index cfd79376d..a7775c162 100644 --- a/cookbooks/nginx/recipes/default.rb +++ b/cookbooks/nginx/recipes/default.rb @@ -68,9 +68,9 @@ template "/usr/local/bin/nginx-old-cache-cleanup" do 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 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 index 9f21e45a0..000000000 --- a/cookbooks/nginx/templates/nginx-old-cache-cleanup.cron.erb +++ /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 diff --git a/cookbooks/piwik/recipes/default.rb b/cookbooks/piwik/recipes/default.rb index 990e1c33e..948c03af4 100644 --- a/cookbooks/piwik/recipes/default.rb +++ b/cookbooks/piwik/recipes/default.rb @@ -123,9 +123,8 @@ apache_site "piwik.openstreetmap.org" do 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 diff --git a/cookbooks/piwik/templates/default/cron.erb b/cookbooks/piwik/templates/default/cron.erb deleted file mode 100644 index 2637b2f5a..000000000 --- a/cookbooks/piwik/templates/default/cron.erb +++ /dev/null @@ -1 +0,0 @@ -5 * * * * www-data /usr/bin/php /srv/piwik.openstreetmap.org/console core:archive --quiet --url=https://piwik.openstreetmap.org/ diff --git a/cookbooks/tilelog/recipes/default.rb b/cookbooks/tilelog/recipes/default.rb index 56d7870f3..4d3ddb512 100644 --- a/cookbooks/tilelog/recipes/default.rb +++ b/cookbooks/tilelog/recipes/default.rb @@ -82,11 +82,12 @@ template "/usr/local/bin/tilelog" do :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 diff --git a/cookbooks/tilelog/templates/default/tilelog.cron.erb b/cookbooks/tilelog/templates/default/tilelog.cron.erb deleted file mode 100644 index bd3278e3a..000000000 --- a/cookbooks/tilelog/templates/default/tilelog.cron.erb +++ /dev/null @@ -1,2 +0,0 @@ -MAILTO=zerebubuth@gmail.com -17 22 * * * www-data /usr/local/bin/tilelog diff --git a/cookbooks/web/recipes/statistics.rb b/cookbooks/web/recipes/statistics.rb index c2f7d9b14..f725e108b 100644 --- a/cookbooks/web/recipes/statistics.rb +++ b/cookbooks/web/recipes/statistics.rb @@ -30,9 +30,9 @@ template "/usr/local/bin/statistics" do 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 diff --git a/cookbooks/web/templates/default/statistics.cron.erb b/cookbooks/web/templates/default/statistics.cron.erb deleted file mode 100644 index 900856cde..000000000 --- a/cookbooks/web/templates/default/statistics.cron.erb +++ /dev/null @@ -1,2 +0,0 @@ -# DO NOT EDIT - This file is being maintained by Chef -0 0 * * * rails /usr/local/bin/statistics diff --git a/cookbooks/wiki/recipes/default.rb b/cookbooks/wiki/recipes/default.rb index 7e9569098..287a645f6 100644 --- a/cookbooks/wiki/recipes/default.rb +++ b/cookbooks/wiki/recipes/default.rb @@ -128,10 +128,9 @@ directory "/srv/wiki.openstreetmap.org/dump" do 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 diff --git a/cookbooks/wiki/templates/default/wiki-dump.erb b/cookbooks/wiki/templates/default/wiki-dump.erb deleted file mode 100644 index 8139f28ad..000000000 --- a/cookbooks/wiki/templates/default/wiki-dump.erb +++ /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