This repository has been archived by the owner on Jun 11, 2019. It is now read-only.
forked from lermit/puppet-php
-
Notifications
You must be signed in to change notification settings - Fork 62
/
module.pp
96 lines (88 loc) · 2.27 KB
/
module.pp
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# = Define: php::module
#
# This define installs and configures php modules
# On Debian and derivatives it install module named php5-${name}
# On RedHat and derivatives it install module named php-${name}
# If you need a custom prefix you can overload default $module_prefix parameter
#
# == Parameters
#
# [*version*]
# Version to install.
#
# [*absent*]
# true to ensure package isn't installed.
#
# [*notify_service*]
# If you want to restart a service automatically when
# the module is applied. Default: true
#
# [*service_autorestart*]
# whatever we want a module installation notify a service to restart.
#
# [*service*]
# Service to restart.
#
# [*module_prefix*]
# If package name prefix isn't standard.
#
# [*install_options*]
# An array of package manager install options. See $php::install_options
#
# == Examples
# php::module { 'gd': }
#
# php::module { 'gd':
# ensure => absent,
# }
#
# This will install php-apc on debian instead of php5-apc
#
# php::module { 'apc':
# module_prefix => "php-",
# }
#
# Note that you may include or declare the php class when using
# the php::module define
#
define php::module (
$version = 'present',
$install_options = [],
$service_autorestart = '',
$module_prefix = '',
$absent = '',
$package = $php::package
) {
include php
if $absent {
$real_version = 'absent'
} else {
$real_version = $version
}
$real_service_autorestart = $service_autorestart ? {
true => "Service[${php::service}]",
false => undef,
'' => $php::service_autorestart ? {
true => "Service[${php::service}]",
false => undef,
}
}
$real_module_prefix = $module_prefix ? {
'' => $php::module_prefix,
default => $module_prefix,
}
$real_install_options = $install_options ? {
'' => $php::install_options,
default => $install_options,
}
$real_install_package = "${real_module_prefix}${name}"
if defined(Package[$real_install_package]) == false {
package { "PhpModule_${name}":
ensure => $real_version,
name => $real_install_package,
notify => $real_service_autorestart,
install_options => $real_install_options,
require => Package[$package],
}
}
}