From 919f44292a8cf265db429257b0f14b0ce5af4dad Mon Sep 17 00:00:00 2001
From: Jonathan Gazeley <jonathan.gazeley@bristol.ac.uk>
Date: Mon, 19 Jun 2017 15:24:54 +0100
Subject: [PATCH] Manage pidfile location and use it to template logrotate
 blocks

---
 manifests/init.pp   | 6 +++---
 manifests/params.pp | 3 +++
 manifests/sql.pp    | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/manifests/init.pp b/manifests/init.pp
index 5450912..d6557d5 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -311,7 +311,7 @@ class freeradius (
     create        => false,
     missingok     => true,
     compress      => true,
-    postrotate    => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`',
+    postrotate    => "kill -HUP `cat ${freeradius::fr_pidfile}`",
     sharedscripts => true,
   }
 
@@ -322,7 +322,7 @@ class freeradius (
     create        => true,
     missingok     => true,
     compress      => true,
-    postrotate    => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`',
+    postrotate    => "kill -HUP `cat ${freeradius::fr_pidfile}`",
     sharedscripts => true,
   }
 
@@ -333,7 +333,7 @@ class freeradius (
     create        => true,
     missingok     => true,
     compress      => true,
-    postrotate    => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`',
+    postrotate    => "kill -HUP `cat ${freeradius::fr_pidfile}`",
     sharedscripts => true,
   }
 
diff --git a/manifests/params.pp b/manifests/params.pp
index 75bae6e..2b14727 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -73,6 +73,9 @@ class freeradius::params {
     default  => false,
   }
 
+  # Default pid file location
+  $fr_pidfile = "/var/run/${fr_service}/${fr_service}.pid"
+
   # Default base path for FreeRADIUS configs
   $fr_basepath = $::osfamily ? {
     'RedHat' => '/etc/raddb',
diff --git a/manifests/sql.pp b/manifests/sql.pp
index dcaeb97..2849186 100644
--- a/manifests/sql.pp
+++ b/manifests/sql.pp
@@ -127,7 +127,7 @@ define freeradius::sql (
       create       => true,
       compress     => true,
       missingok    => true,
-      postrotate   => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`',
+      postrotate   => "kill -HUP `cat ${freeradius::fr_pidfile}`",
     }
   }
 }
-- 
GitLab