Configure a machine to run the database cleanup script each day
authorTom Hughes <tom@compton.nu>
Fri, 9 Aug 2013 16:39:43 +0000 (17:39 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 9 Aug 2013 16:40:04 +0000 (17:40 +0100)
cookbooks/web/recipes/cleanup.rb [new file with mode: 0644]
cookbooks/web/templates/default/cleanup.cron.erb [new file with mode: 0644]
roles/spike-01.rb
roles/web-cleanup.rb [new file with mode: 0644]

diff --git a/cookbooks/web/recipes/cleanup.rb b/cookbooks/web/recipes/cleanup.rb
new file mode 100644 (file)
index 0000000..8b8faca
--- /dev/null
@@ -0,0 +1,27 @@
+#
+# Cookbook Name:: web
+# Recipe:: cleanup
+#
+# Copyright 2013, OpenStreetMap Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe "web::base"
+
+template "/etc/cron.daily/web-cleanup" do
+  source "cleanup.cron.erb"
+  owner "root"
+  group "root"
+  mode 0755
+end
diff --git a/cookbooks/web/templates/default/cleanup.cron.erb b/cookbooks/web/templates/default/cleanup.cron.erb
new file mode 100644 (file)
index 0000000..996aeec
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+<%= node[:web][:base_directory] %>/rails/script/cleanup
index 84622aea0bc19792d7800de4f4960be132c0fdad..97fec5fd2297ac5359b2d1910284a19aefe67af1 100644 (file)
@@ -30,5 +30,6 @@ run_list(
   "role[ic]",
   "role[web-frontend]",
   "role[web-gpximport]",
-  "role[web-statistics]"
+  "role[web-statistics]",
+  "role[web-cleanup]"
 )
diff --git a/roles/web-cleanup.rb b/roles/web-cleanup.rb
new file mode 100644 (file)
index 0000000..26b2fd4
--- /dev/null
@@ -0,0 +1,7 @@
+name "web-cleanup"
+description "Role applied to all web/api database cleanup servers"
+
+run_list(
+  "role[web]",
+  "recipe[web::cleanup]"
+)