]> gitweb.fluxo.info Git - puppet-apache.git/commitdiff
Adding more configuration into VirtualHost definition
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 5 Nov 2009 17:39:01 +0000 (15:39 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 5 Nov 2009 17:39:01 +0000 (15:39 -0200)
manifests/init.pp
templates/website.erb

index 7ec5169eaf0a849cf4fdd2df31c0af6dbc4a6bf2..3c5caf877fda39f4bac159064b40390fb314b879 100644 (file)
@@ -21,8 +21,6 @@
 
 # TODO: log level, log files, etc
 # TODO: better variable names, enable value overwriting
-$apache_sites_folder = '/var/users/home';
-$apache_www_folder   = '/var/www/sarava';
 
 class apache {
 
@@ -51,8 +49,18 @@ class apache {
     notify  => Service["apache"],
   }
 
+  # prepare variables to use in templates
+  case $apache_sites_folder {
+    '': { $apache_sites_folder = '/var/www/sites' }
+  }
+
+  case $apache_www_folder {
+    '': { $apache_www_folder= '/var/www' }
+  }
+
   # TODO: ensure folders exist with right modes and ownership
-  define website($ensure = present, $alias = [], $use = []) {
+  define website($ensure = present, $docroot = false, $redirect = false,
+                 $protocol = 'http', $alias = false, $use = false) {
     file { "/etc/apache2/sites-available/$title":
       ensure  => $ensure,
       content => template('apache/website.erb'),
index 56be471f0f7878eba325dba04df7848316f028d9..156b4b101ce0911758a74bee9661c9553cce67bb 100644 (file)
@@ -1,6 +1,18 @@
-# begin vhost for <%= $title %>
+# begin vhost for <%= title %>
 <VirtualHost *:80>
-   # TODO
-   ServerName <%= $title %>.<%= $domain %>
+   ServerName <%= title %>.<%= domain %>
+<% if alias != false %>
+   ServerAlias <%= alias %>
+<% end %>
+   DocumentRoot <%= docroot %>
+<% if redirect != false %>       
+   RedirectMatch ^/$ <%= protocol %>://<%= title %>.<%= domain %>/<%= redirect %>
+<% end %>
+
+<% if use != false %>
+  <% use.each do |instance| -%> 
+   Use <%= instance %> 
+  <% end -%>
+<% end -%>
 </VirtualHost>
-# end vhost for <%= $title %>
+# end vhost for <%= title %>