From 7e07d48d16630d547b86670b4c66164b18f5492b Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 5 Nov 2009 17:45:20 -0200 Subject: Ensuring mod_macro is enabled --- manifests/init.pp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'manifests') diff --git a/manifests/init.pp b/manifests/init.pp index 68d7918..8381ed0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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'" ) } + } + } } -- cgit v1.2.3