From 2bca224b7c83862b9e2b5ed31eaad75510fc8953 Mon Sep 17 00:00:00 2001
From: "James E. Blair" <jeblair@linux.vnet.ibm.com>
Date: Wed, 6 Jan 2016 08:15:06 -0800
Subject: [PATCH] Redirect puppet cron output to a log file

The _ansible_ output (mostly consisting of puppet output) is now sent
to the puppet_run_all log file, but there is still quite a bit of
output from ancilary parts of the cron job that just gets sent in
email to infra-root every few minutes.  Send it to a log file.

Change-Id: I1f382b2d376cbfc2eff430c897bd3737fd585373
---
 .../openstack_project/manifests/puppetmaster.pp  | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/modules/openstack_project/manifests/puppetmaster.pp b/modules/openstack_project/manifests/puppetmaster.pp
index 27b760909c..8fea9263ed 100644
--- a/modules/openstack_project/manifests/puppetmaster.pp
+++ b/modules/openstack_project/manifests/puppetmaster.pp
@@ -36,7 +36,7 @@ class openstack_project::puppetmaster (
     monthday    => $puppetmaster_update_cron_interval[day],
     month       => $puppetmaster_update_cron_interval[month],
     weekday     => $puppetmaster_update_cron_interval[weekday],
-    command     => 'flock -n /var/run/puppet/puppet_run_all.lock bash /opt/system-config/production/run_all.sh',
+    command     => 'flock -n /var/run/puppet/puppet_run_all.lock bash /opt/system-config/production/run_all.sh >> /var/log/puppet_run_all_cron.log 2>&1',
     environment => 'PATH=/var/lib/gems/1.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',
   }
 
@@ -54,6 +54,20 @@ class openstack_project::puppetmaster (
     require => Cron['updatepuppetmaster'],
   }
 
+  logrotate::file { 'updatepuppetmastercron':
+    ensure  => present,
+    log     => '/var/log/puppet_run_all_cron.log',
+    options => ['compress',
+      'copytruncate',
+      'delaycompress',
+      'missingok',
+      'rotate 7',
+      'daily',
+      'notifempty',
+    ],
+    require => Cron['updatepuppetmaster'],
+  }
+
   cron { 'deleteoldreports':
     user        => 'root',
     hour        => '3',