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
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
|
# File 'manifests/mod/php.pp', line 1
class apache::mod::php (
$package_name = undef,
$package_ensure = 'present',
$path = undef,
$extensions = ['.php'],
$content = undef,
$template = 'apache/mod/php.conf.erb',
$source = undef,
$root_group = $::apache::params::root_group,
$php_version = $::apache::params::php_version,
) inherits apache::params {
$mod = "php${php_version}"
if defined(Class['::apache::mod::prefork']) {
Class['::apache::mod::prefork']->File["${mod}.conf"]
}
elsif defined(Class['::apache::mod::itk']) {
Class['::apache::mod::itk']->File["${mod}.conf"]
}
else {
fail('apache::mod::php requires apache::mod::prefork or apache::mod::itk; please enable mpm_module => \'prefork\' or mpm_module => \'itk\' on Class[\'apache\']')
}
validate_array($extensions)
if $source and ($content or $template != 'apache/mod/php.conf.erb') {
warning('source and content or template parameters are provided. source parameter will be used')
} elsif $content and $template != 'apache/mod/php.conf.erb' {
warning('content and template parameters are provided. content parameter will be used')
}
$manage_content = $source ? {
undef => $content ? {
undef => template($template),
default => $content,
},
default => undef,
}
# Determine if we have a package
$mod_packages = $::apache::params::mod_packages
if $package_name {
$_package_name = $package_name
} elsif has_key($mod_packages, $mod) { # 2.6 compatibility hack
$_package_name = $mod_packages[$mod]
} elsif has_key($mod_packages, 'phpXXX') { # 2.6 compatibility hack
$_package_name = regsubst($mod_packages['phpXXX'], 'XXX', $php_version)
} else {
$_package_name = undef
}
$_lib = "libphp${php_version}.so"
$_php_major = regsubst($php_version, '^(\d+)\..*$', '\1')
::apache::mod { $mod:
package => $_package_name,
package_ensure => $package_ensure,
lib => $_lib,
id => "php${_php_major}_module",
path => $path,
}
include ::apache::mod::mime
include ::apache::mod::dir
Class['::apache::mod::mime'] -> Class['::apache::mod::dir'] -> Class['::apache::mod::php']
# Template uses $extensions
file { "${mod}.conf":
ensure => file,
path => "${::apache::mod_dir}/${mod}.conf",
owner => 'root',
group => $root_group,
mode => $::apache::file_mode,
content => $manage_content,
source => $source,
require => [
Exec["mkdir ${::apache::mod_dir}"],
],
before => File[$::apache::mod_dir],
notify => Class['apache::service'],
}
}
|