Defined Type: apache::mpm

Defined in:
manifests/mpm.pp

Summary

Enables the use of Apache MPMs.

Overview

Parameters:

  • lib_path (String) (defaults to: $apache::lib_path)
  • apache_version (Optional[String]) (defaults to: $apache::apache_version)


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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'manifests/mpm.pp', line 4

define apache::mpm (
  String $lib_path                 = $apache::lib_path,
  Optional[String] $apache_version = $apache::apache_version,
) {
  if ! defined(Class['apache']) {
    fail('You must include the apache base class before using any apache defined resources')
  }

  $mpm     = $name
  $mod_dir = $apache::mod_dir

  $_lib  = "mod_mpm_${mpm}.so"
  $_path = "${lib_path}/${_lib}"
  $_id   = "mpm_${mpm}_module"

  if $facts['os']['family'] == 'Suse' {
    #mpms on Suse 12 don't use .so libraries so create a placeholder load file
    if versioncmp($apache_version, '2.4') >= 0 {
      file { "${mod_dir}/${mpm}.load":
        ensure  => file,
        path    => "${mod_dir}/${mpm}.load",
        content => '',
        require => [
          Package['httpd'],
          Exec["mkdir ${mod_dir}"],
        ],
        before  => File[$mod_dir],
        notify  => Class['apache::service'],
      }
    }
  } else {
    if versioncmp($apache_version, '2.4') >= 0 {
      file { "${mod_dir}/${mpm}.load":
        ensure  => file,
        path    => "${mod_dir}/${mpm}.load",
        content => "LoadModule ${_id} ${_path}\n",
        require => [
          Package['httpd'],
          Exec["mkdir ${mod_dir}"],
        ],
        before  => File[$mod_dir],
        notify  => Class['apache::service'],
      }
    }
  }

  case $facts['os']['family'] {
    'debian': {
      file { "${apache::mod_enable_dir}/${mpm}.conf":
        ensure  => link,
        target  => "${apache::mod_dir}/${mpm}.conf",
        require => Exec["mkdir ${apache::mod_enable_dir}"],
        before  => File[$apache::mod_enable_dir],
        notify  => Class['apache::service'],
      }

      if versioncmp($apache_version, '2.4') >= 0 {
        file { "${apache::mod_enable_dir}/${mpm}.load":
          ensure  => link,
          target  => "${apache::mod_dir}/${mpm}.load",
          require => Exec["mkdir ${apache::mod_enable_dir}"],
          before  => File[$apache::mod_enable_dir],
          notify  => Class['apache::service'],
        }

        if $mpm == 'itk' {
          file { "${lib_path}/mod_mpm_itk.so":
            ensure  => link,
            target  => "${lib_path}/mpm_itk.so",
            require => Package['httpd'],
            before  => Class['apache::service'],
          }
        }
      } else {
        package { "apache2-mpm-${mpm}":
          ensure => present,
          before => [
            Class['apache::service'],
            File[$apache::mod_enable_dir],
          ],
        }
      }

      if $mpm == 'itk' {
        package { 'libapache2-mpm-itk':
          ensure => present,
          before => [
            Class['apache::service'],
            File[$apache::mod_enable_dir],
          ],
        }
      }

      unless $mpm in ['itk', 'prefork'] {
        include apache::mpm::disable_mpm_prefork
      }

      if $mpm != 'worker' {
        include apache::mpm::disable_mpm_worker
      }

      if $mpm != 'event' {
        include apache::mpm::disable_mpm_event
      }
    }

    'freebsd': {
      class { 'apache::package':
        mpm_module => $mpm,
      }
    }
    'gentoo': {
      # so we don't fail
    }
    'redhat': {
      # so we don't fail
    }
    'Suse': {
      file { "${apache::mod_enable_dir}/${mpm}.conf":
        ensure  => link,
        target  => "${apache::mod_dir}/${mpm}.conf",
        require => Exec["mkdir ${apache::mod_enable_dir}"],
        before  => File[$apache::mod_enable_dir],
        notify  => Class['apache::service'],
      }

      if versioncmp($apache_version, '2.4') >= 0 {
        file { "${apache::mod_enable_dir}/${mpm}.load":
          ensure  => link,
          target  => "${apache::mod_dir}/${mpm}.load",
          require => Exec["mkdir ${apache::mod_enable_dir}"],
          before  => File[$apache::mod_enable_dir],
          notify  => Class['apache::service'],
        }

        if $mpm == 'itk' {
          file { "${lib_path}/mod_mpm_itk.so":
            ensure => link,
            target => "${lib_path}/mpm_itk.so",
          }
        }
      }

      package { "apache2-${mpm}":
        ensure => present,
      }
    }
    default: {
      fail("Unsupported osfamily ${$facts['os']['family']}")
    }
  }
}