From 12a8dea4e2257372dddcfa19f11bfc20f2780c14 Mon Sep 17 00:00:00 2001
From: Thomas Bellman <bellman@nsc.liu.se>
Date: Wed, 5 Feb 2014 19:14:21 +0100
Subject: [PATCH] Abstract the Apache service into a separate class.

In order for users to not need to know that the service is named
'httpd' (at least on RedHat:ish systems), the class apache::service
is added, abstracting that knowledge.
---
 manifests/init.pp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/manifests/init.pp b/manifests/init.pp
index f6734be..f9607a5 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -30,6 +30,7 @@ class apache
 class apache::base
 {
     include apache
+    include apache::service
 
     package {
 	'httpd':
@@ -41,7 +42,7 @@ class apache::base
 	$apache::configdir:
 	    ensure => directory,
 	    recurse => true, purge => true, force => true, backup => false,
-	    require => Package['httpd'], notify => Service['httpd'];
+	    require => Package['httpd'], notify => Class[apache::service];
     }
     # We do not want to blindly include things in the conf.d directory.
     ensure_line {
@@ -50,8 +51,19 @@ class apache::base
 	    line => '##--Include conf.d/*.conf',
 	    pattern => '^\s*Include\s+conf\.d/\*\.conf\s*$',
 	    require => Package['httpd'],
-	    notify => Service['httpd'];
+	    notify => Class[apache::service];
     }
+}
+
+
+
+/*
+ * Helper class for abstracting dependencies on the Apache service.
+ * This is so others can do e.g. notify => Class[apache::service] instead
+ * of having to do notify => Service['httpd'].
+ */
+class apache::service
+{
     service {
 	'httpd':
 	    enable => true, ensure => $running,
-- 
GitLab