From dbae6afedaca08b2ce86c546c5b35b411c5bcaa2 Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Mon, 3 Apr 2017 11:06:31 -0700
Subject: [PATCH] Run htcacheclean to clean mirror caches

Now that we have reverse proxy caching on our mirror nodes set up
htcacheclean to run their hourly and reduce the size of the cache to
2GB. Based on using the cache lightly for a few days the max size of the
cache has been 648MB so 2GB should be plenty of headroom while still
being well under available disk on our mirror nodes.

Change-Id: I3fe41a3de669d08966357e10d4c121caa9bab6d4
---
 modules/openstack_project/manifests/mirror.pp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/modules/openstack_project/manifests/mirror.pp b/modules/openstack_project/manifests/mirror.pp
index 4b8e3b56cd..68fa5bd4e8 100644
--- a/modules/openstack_project/manifests/mirror.pp
+++ b/modules/openstack_project/manifests/mirror.pp
@@ -267,6 +267,23 @@ class openstack_project::mirror (
     ]
   }
 
+  # Cache cleanup
+  package { 'apache2-utils':
+    ensure => present,
+  }
+
+  cron { 'apache-cache-cleanup':
+    # Clean apache cache once an hour, keep size down to 2GB.
+    minute      => '0',
+    hour        => '*',
+    command     => 'htcacheclean -n -p /opt/apache_cache -t -l 2048M > /dev/null',
+    environment => 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',
+    require     => [
+       File['/opt/apache_cache'],
+       Package['apache2-utils'],
+    ],
+  }
+
   class { '::httpd::logrotate':
     options => [
       'daily',