]> gitweb.fluxo.info Git - puppet-apache.git/commitdiff
Adding website definition
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 3 Nov 2009 19:50:41 +0000 (17:50 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 3 Nov 2009 19:50:41 +0000 (17:50 -0200)
manifests/init.pp
templates/macros.erb [moved from templates/macros with 78% similarity]
templates/website.erb [new file with mode: 0644]

index 782ac6fe7a3caef58434c9a2b6803a9aeb288e75..5172678ee707f41cb5e0e4b31c256dfcaca14ff7 100644 (file)
@@ -1,4 +1,28 @@
-# apache class
+#
+# Puppet module for Apache
+#
+# This module is distributed under the GNU Affero General Public License:
+# 
+# Backup module for puppet
+# Copyright (C) 2009 Sarava Group
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# 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 {
 
@@ -9,5 +33,42 @@ class apache {
     require => Package["apache"],
   }
 
-}
+  # apache mod_macro configuration
+  file { "/etc/apache2/conf.d/macros":
+    ensure  => present,
+    content => template('apache/macros.erb'),
+    owner   => root,
+    group   => root,
+    mode    => 0644,
+    require => Service["apache"],
+    notify  => Service["apache"],
+  }
+
+  # TODO: ensure folders exist with right modes and ownership
+  define website($ensure = present, $drupal = false, $pmwiki = false,
+                 $moin = false, $trac = false, $ikiwiki = false,
+                 $custom = false) {
+    file { "/etc/apache2/sites-available/$title":
+      ensure  => $ensure,
+      content => template('apache/website.erb'),
+      owner   => root,
+      group   => root,
+      mode    => 0644,
+      require => Service["apache"],
+      notify  => Service["apache"],
+    }
 
+    $status = $ensure ? {
+      'present' => "/etc/apache2/sites-available/$title",
+      default   => 'absent',
+    }
+
+    file { "/etc/apache2/sites-enabled/$title":
+      ensure  => $status,
+      owner   => root,
+      group   => root,
+      require => File["/etc/apache2/sites-available/$title"],
+      notify  => Service["apache"],
+    }
+  }
+}
similarity index 78%
rename from templates/macros
rename to templates/macros.erb
index e40bcd508b8f7923356737954fd9281010867aec..1a9d05c9c345e814c30fb3f1a3bc7d1221bd37bb 100644 (file)
@@ -18,7 +18,7 @@
 
 <Macro Drupal $version>
    # begin drupal config
-   <Directory /var/www/sarava/drupal-$version>
+   <Directory <%= apache_www_folder %>/drupal-$version>
       Options Indexes Includes FollowSymLinks MultiViews
       AllowOverride All
    </Directory>
@@ -27,7 +27,7 @@
 
 <Macro Wiki $site>
    # begin wiki config
-   <Directory /var/users/home/$site/wiki>
+   <Directory <%= apache_sites_folder %>/$site/wiki>
       Options Indexes Includes FollowSymLinks MultiViews
       AllowOverride All
    </Directory>
@@ -36,7 +36,7 @@
 
 <Macro Site $name>
    # begin site config
-   <Directory /var/users/home/$name/site>
+   <Directory <%= apache_sites_folder %>/$name/site>
       Options Indexes Includes FollowSymLinks MultiViews
       AllowOverride All
    </Directory>
@@ -49,7 +49,7 @@
      SetHandler mod_python
      PythonInterpreter main_interpreter
      PythonHandler trac.web.modpython_frontend
-     PythonOption TracEnv /var/users/home/$site/trac
+     PythonOption TracEnv <%= apache_sites_folder %>/$site/trac
      PythonOption TracUriRoot /trac
 
      # This prevents strange behavior when using trac
@@ -61,7 +61,7 @@
    <Location "/trac/login">
      AuthType Basic
      AuthName "Trac $site"
-     AuthUserFile /var/users/home/$site/trac/auth/.htpasswd
+     AuthUserFile <%= apache_sites_folder %>/$site/trac/auth/.htpasswd
      Require valid-user
    </Location>
    # end trac config
    # begin moin config
    Alias /moinroot /usr/share/moin/htdocs/
    # TODO: fastcgi
-   ScriptAlias /moin "/var/users/home/$site/moin/cgi-bin/moin.cgi"
+   ScriptAlias /moin "<%= apache_sites_folder %>/$site/moin/cgi-bin/moin.cgi"
    # end moin config
-   ScriptAlias /moin "/var/users/home/$site/moin/cgi-bin/moin.cgi"
+   ScriptAlias /moin "<%= apache_sites_folder %>/$site/moin/cgi-bin/moin.cgi"
    # end moin config
 </Macro>
 
 <Macro Ikiwiki $name>
    # begin ikiwiki config
-   <Directory /var/users/home/$name/ikiwiki>
+   <Directory <%= apache_sites_folder %>/$name/ikiwiki>
       Options Indexes Includes FollowSymLinks MultiViews ExecCGI
       AllowOverride All
    </Directory>
diff --git a/templates/website.erb b/templates/website.erb
new file mode 100644 (file)
index 0000000..3398f60
--- /dev/null
@@ -0,0 +1 @@
+# TODO: virtual host definition