changeset 12:72466547cc79

Update HTTP website manifest so that it works, since we're now hosting a HTTP site
author IBBoard <dev@ibboard.co.uk>
date Mon, 01 Dec 2014 20:27:38 +0000
parents 4b42f65ae875
children db4934b7ab12
files modules/website/manifests/http.pp
diffstat 1 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/website/manifests/http.pp	Sat Nov 08 15:36:42 2014 +0000
+++ b/modules/website/manifests/http.pp	Mon Dec 01 20:27:38 2014 +0000
@@ -1,5 +1,5 @@
-define website(
-    $docroot,
+define website::http(
+    $docroot            = undef,
     $docroot_owner      = 'root',
     $docroot_group      = 'root',
     $serveraliases      = [],
@@ -10,15 +10,26 @@
   "${ensure} is not supported for ensure.
   Allowed values are 'present' and 'absent'.")
 
-  if $name =~ /^([^\.]+)\./ {
-    $logpart = $1
+  if ! defined(Class['website']) {
+    fail('You must include the website base class before using any website defined resources')
+  }
+
+  validate_re($ensure, '^(present|absent)$',
+  "${ensure} is not supported for ensure.
+  Allowed values are 'present' and 'absent'.")
+
+  $shortname = domain_to_short_name($name)
+  $logpart = $shortname
+
+  if $docroot == undef {
+    $siteroot = "${website::basedir}/${shortname}"
   } else {
-    $logpart = $name
+    $siteroot = $docroot
   }
 
   apache::vhost { $name:
     port            => '80',
-    docroot         => $docroot,
+    docroot         => $siteroot,
     docroot_owner   => $docroot_owner,
     docroot_group   => $docroot_group,
     custom_fragment => $custom_fragment,