From: Tom Hughes Date: Tue, 21 Jul 2020 18:19:02 +0000 (+0100) Subject: Replace cron.d templates with cron_d resources X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/168654c76af6d2d6193a15051e684b9b6bfde0ab Replace cron.d templates with cron_d resources --- diff --git a/cookbooks/tile/recipes/default.rb b/cookbooks/tile/recipes/default.rb index 5dafa2fd8..c5dc7c87f 100644 --- a/cookbooks/tile/recipes/default.rb +++ b/cookbooks/tile/recipes/default.rb @@ -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 index 28c631a58..000000000 --- a/cookbooks/tile/templates/default/cleanup-tiles.cron.erb +++ /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 -%> diff --git a/cookbooks/tilecache/recipes/default.rb b/cookbooks/tilecache/recipes/default.rb index 2358394e1..9ec7b2aeb 100644 --- a/cookbooks/tilecache/recipes/default.rb +++ b/cookbooks/tilecache/recipes/default.rb @@ -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 index ab8ad8397..000000000 --- a/cookbooks/tilecache/templates/default/cron.erb +++ /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