summaryrefslogtreecommitdiff
path: root/manifests/debian/module.pp
blob: 19ac7b6b1afa51c0c97e515a3ef64fecad8bbb86 (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
26
27
28
29
30
31
32
33
34
35
36
37
define apache::debian::module(
    $ensure = present,
    $package_name = 'absent'
){
    $modules_dir = "$apache::debian::config_dir/mods"

    if ($package_name != 'absent') {
        package { "${package_name}":
            ensure => $ensure,
            notify => Service['apache'],
            require => Package['apache'],
        }
    }

    case $ensure {
        'present' : {
            exec { "/usr/sbin/a2enmod ${name}":
                unless => "/bin/sh -c '[ -L ${modules_dir}-enabled/${name}.load ] \\
                    && [ ${modules_dir}-enabled/${name}.load -ef ${modules_dir}-available/${name}.load ]'",
                notify => Service['apache'],
                require => $package_name ? {
                    'absent' => Package['apache'],
                    default => Package[['apache',$package_name]],
                },
            }
        }
        'absent': {
            exec { "/usr/sbin/a2dismod ${name}":
                onlyif => "/bin/sh -c '[ -L ${modules_dir}-enabled/${name}.load ] \\
                    && [ ${modules_dir}-enabled/${name}.load -ef ${modules_dir}-available/${name}.load ]'",
                notify => Service['apache'],
                require => Package['apache'],
            }
        }
    }
}