From 21ab83c0b5fcf508d3b5ce7cb5bfda7076f73aa2 Mon Sep 17 00:00:00 2001
From: Monty Taylor <mordred@inaugust.com>
Date: Fri, 18 Apr 2014 13:53:36 -0700
Subject: [PATCH] Add some system logging to run_all

When we want to watch run_all happen, it's hard, because there is
no logging. To fix that - make there be some logging. Then, rotate
the logs.

Change-Id: I0eed7aeeec0ff21e58d57d6385cc59b74bbf31fb
---
 .../openstack_project/manifests/puppetmaster.pp    | 14 ++++++++++++++
 run_all.sh                                         |  4 +++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/modules/openstack_project/manifests/puppetmaster.pp b/modules/openstack_project/manifests/puppetmaster.pp
index d6bc2d96bb..641cbdff24 100644
--- a/modules/openstack_project/manifests/puppetmaster.pp
+++ b/modules/openstack_project/manifests/puppetmaster.pp
@@ -5,6 +5,7 @@ class openstack_project::puppetmaster (
   $override_list = [],
   $sysadmins = []
 ) {
+  include logrotate
   include openstack_project::params
 
   class { 'openstack_project::server':
@@ -23,6 +24,19 @@ class openstack_project::puppetmaster (
     command     => 'bash /opt/config/production/run_all.sh',
     environment => 'PATH=/var/lib/gems/1.8/bin:/usr/bin:/bin:/usr/sbin:/sbin',
   }
+  logrotate::file { 'updatepuppetmaster':
+    ensure  => present,
+    log     => '/var/log/puppet_run_all.log',
+    options => ['compress',
+      'copytruncate',
+      'delaycompress',
+      'missingok',
+      'rotate 7',
+      'daily',
+      'notifempty',
+    ],
+    require => Cron['updatepuppetmaster'],
+  }
 
   cron { 'deleteoldreports':
     user        => 'root',
diff --git a/run_all.sh b/run_all.sh
index 6f35c43359..0d654ac040 100755
--- a/run_all.sh
+++ b/run_all.sh
@@ -23,5 +23,7 @@ git fetch -a && git reset -q --hard @{u}
 # some times
 touch manifests/site.pp
 
+# Put in a logging header
+echo "****\n\n$(date)\n\n****" >> /var/log/puppet_run_all.log 2>&1
 # Run this as an external script so that the above pull will get new changes
-/usr/local/bin/run_remote_puppet
+/usr/local/bin/run_remote_puppet >> /var/log/puppet_run_all.log 2>&1