summaryrefslogtreecommitdiff
path: root/manifests/module.pp
blob: 64a692c8557bc6c9b1a612d49132478cb75bc2a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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 apache::module($ensure = 'present') {
  case $ensure {
    'present': {
      exec { "/usr/sbin/a2enmod $name":
        unless  => "/bin/sh -c '[ -L ${apache::mods}-enabled/${name}.load ] \
                && [ ${apache::mods}-enabled/${name}.load -ef ${apache::mods}-available/${name}.load ]'",
        notify  => Exec["force-reload-apache2"],
      }
    }
    'absent': {
      exec { "/usr/sbin/a2dismod $name":
        onlyif  => "/bin/sh -c '[ -L ${apache::mods}-enabled/${name}.load ] \
                && [ ${apache::mods}-enabled/${name}.load -ef ${apache::mods}-available/${name}.load ]'",
        notify  => Exec["force-reload-apache2"],
      }
    }
    default: { err ("Unknown ensure value: '$ensure'") }
  }
}