]> gitweb.fluxo.info Git - puppet-apache.git/commitdiff
Ensuring mod_macro is enabled
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 5 Nov 2009 19:45:20 +0000 (17:45 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 5 Nov 2009 19:45:20 +0000 (17:45 -0200)
manifests/init.pp

index 68d7918fd0dfbf91f903f884796e7fe2e9cbb7d5..8381ed074eac50f1442d59df3ef0e38878e1e347 100644 (file)
@@ -29,7 +29,6 @@ class apache {
     ensure => installed,
   }
 
-  # TODO: enable mod_macro
   package { "mod_macro":
     name    => "libapache2-mod-macro",
     ensure  => installed,
@@ -51,6 +50,11 @@ class apache {
     notify  => Service["apache"],
   }
 
+  module { "macro":
+    ensure  => present,
+    require => "mod_macro",
+  }
+
   # prepare variables to use in templates
   case $apache_sites_folder {
     '': { $apache_sites_folder = '/var/www/sites' }
@@ -85,4 +89,33 @@ class apache {
       notify  => Service["apache"],
     }
   }
+
+  # Code from http://reductivelabs.com/trac/puppet/wiki/Recipes/DebianApache2Recipe
+  # Define an apache2 module. Debian packages place the module config
+  # into /etc/apache2/mods-available.
+  #
+  # You can add a custom require (string) if the module depends on 
+  # packages that aren't part of the default apache2 package. Because of 
+  # the package dependencies, apache2 will automagically be included.
+  define module ( $ensure = 'present', $require = 'apache2' ) {
+    case $ensure {
+      'present' : {
+        exec { "/usr/sbin/a2enmod $name":
+          unless => "/bin/sh -c '[ -L ${apache2_mods}-enabled/${name}.load ] \
+                  && [ ${apache2_mods}-enabled/${name}.load -ef ${apache2_mods}-available/${name}.load ]'",
+                 notify => Exec["force-reload-apache2"],
+                 require => Package[$require],
+        }
+      }
+      'absent': {
+        exec { "/usr/sbin/a2dismod $name":
+          onlyif => "/bin/sh -c '[ -L ${apache2_mods}-enabled/${name}.load ] \
+                  && [ ${apache2_mods}-enabled/${name}.load -ef ${apache2_mods}-available/${name}.load ]'",
+                 notify => Exec["force-reload-apache2"],
+                 require => Package["apache2"],
+        }
+      }
+      default: { err ( "Unknown ensure value: '$ensure'" ) }
+    }
+  }
 }