]> git.openstreetmap.org Git - chef.git/commitdiff
Replace cron.d templates with cron_d resources
authorTom Hughes <tom@compton.nu>
Tue, 21 Jul 2020 18:19:02 +0000 (19:19 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 21 Jul 2020 18:21:16 +0000 (19:21 +0100)
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/cleanup-tiles.cron.erb [deleted file]
cookbooks/tilecache/recipes/default.rb
cookbooks/tilecache/templates/default/cron.erb [deleted file]

index 5dafa2fd85cc3f7f11a783e9d21e192a242e76d0..c5dc7c87fa047c1434840043d223103f1426bf94 100644 (file)
@@ -578,12 +578,19 @@ tile_directories = node[:tile][:styles].collect do |_, style|
   style[:tile_directories].collect { |directory| directory[:name] }
 end.flatten.sort.uniq
 
-template "/etc/cron.d/cleanup-tiles" do
-  source "cleanup-tiles.cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
-  variables :directories => tile_directories
+file "/etc/cron.d/cleanup-tiles" do
+  action :delete
+end
+
+tile_directories.each do |directory|
+  label = directory.gsub("/", "-")
+
+  cron_d "cleanup-tiles#{label}" do
+    minute "0"
+    user "www-data"
+    command "ionice -c 3 /usr/local/bin/cleanup-tiles #{directory}"
+    mailto "admins@openstreetmap.org"
+  end
 end
 
 munin_plugin "mod_tile_fresh"
diff --git a/cookbooks/tile/templates/default/cleanup-tiles.cron.erb b/cookbooks/tile/templates/default/cleanup-tiles.cron.erb
deleted file mode 100644 (file)
index 28c631a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-MAILTO=admins@openstreetmap.org
-
-<% @directories.each do |directory| -%>
-0 * * * * www-data ionice -c 3 /usr/local/bin/cleanup-tiles <%= directory %>
-<% end -%>
index 2358394e120c319763743dd07469a3b34e9e3b4d..9ec7b2aeb6ef87f403beef7bf1d6c18cee8aecfb 100644 (file)
@@ -123,11 +123,26 @@ template "/usr/local/bin/nginx_generate_tilecache_qos_map" do
   variables :totp_key => web_passwords["totp_key"]
 end
 
-template "/etc/cron.d/tilecache" do
-  source "cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+file "/etc/cron.d/tilecache" do
+  action :delete
+end
+
+cron_d "tilecache-generate-qos-map" do
+  minute "0"
+  user "root"
+  command "/usr/local/bin/nginx_generate_tilecache_qos_map"
+end
+
+cron_d "tilecache-curl-time" do
+  user "www-data"
+  command "/srv/tilecache/tilecache-curl-time"
+end
+
+cron_d "tilecache-curl-time-cleanup" do
+  minute "15"
+  hour "0"
+  user "www-data"
+  command "/srv/tilecache/tilecache-curl-time-cleanup"
 end
 
 execute "execute_nginx_generate_tilecache_qos_map" do
diff --git a/cookbooks/tilecache/templates/default/cron.erb b/cookbooks/tilecache/templates/default/cron.erb
deleted file mode 100644 (file)
index ab8ad83..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-0 * * * * root /usr/local/bin/nginx_generate_tilecache_qos_map
-* * * * * www-data /srv/tilecache/tilecache-curl-time
-15 0 * * * www-data /srv/tilecache/tilecache-curl-time-cleanup