Skip to content

Commit 31be589

Browse files
author
Alexander Schneider
committed
Update module file
Update readme file Add parameter for install path Add php ini parameter
1 parent f186850 commit 31be589

File tree

6 files changed

+83
-28
lines changed

6 files changed

+83
-28
lines changed

Modulefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name 'phpbrew'
1+
name 'puppet-phpbrew'
22
version '1.0.1'
33
author 'Jankowfsky AG - Alexander Schneider'
44
description 'Puppet module for phpbrew.'

README.md

+40-15
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,55 @@ Puppet module for phpbrew.
55

66
## Usage
77

8-
class { 'phpdecoder':
9-
$php_version => '5.3',
10-
$type => 'zend',
11-
}
8+
phpbrew::install{ '5.3.27':
9+
$version = '',
10+
$build_prameters = undef,
11+
$php_inis = undef,
12+
$install_dir = '/opt/phpbrew',
13+
)
1214

1315

1416
## Configuration
1517

16-
You can additional define apache modules and php conf.d directory:
18+
You can additional define the version (if the name should be different), the build parameters, the php ini files you want to copy and the install directory:
1719

18-
class { 'phpdecoder':
19-
$php_version => '5.3',
20-
$type => 'zend',
21-
$modules_dir => '/etc/apache2/modules/zgl/',
22-
$php_ini_dir => '/etc/php5/apache2/conf.d/'
23-
}
20+
phpbrew::install{ 'php-5.3.27':
21+
$version => '5.3.27',
22+
$build_prameters => '+mysql',
23+
$php_inis => [
24+
'/etc/php5/mods-available/custom.ini'
25+
],
26+
$install_dir => '/opt/custom_dir',
27+
)
2428

29+
Default values:
30+
31+
$version = '',
32+
$build_prameters = undef
33+
$php_inis = undef
34+
$install_dir = '/opt/phpbrew'
35+
36+
37+
## Install php extension
38+
39+
### Usage
40+
41+
define phpbrew::extension{ 'xdebug':
42+
$php_version = '5.3.27',
43+
)
44+
45+
Note the php version is required and the php version must be installed by php brew.
46+
47+
48+
### Configuration
49+
50+
You can additional define the extension name (if the name should be different), the version (if now version is given the latest will used), the build parameters and the install directory:
2551

2652
Default values:
2753

28-
$php_version = '5.3'
29-
$type = 'zend'
30-
$modules_dir = '/etc/apache2/modules/zgl/'
31-
$php_ini_dir = '/etc/php5/apache2/conf.d/'
54+
$extension = undef
55+
$version = undef
56+
$install_dir = '/opt/phpbrew'
3257

3358

3459
## License

manifests/extension.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
define phpbrew::extension(
1818
$extension = undef,
1919
$php_version = undef,
20-
$version = undef
20+
$version = undef,
21+
$install_dir = '/opt/phpbrew',
2122
) {
2223
if ! $extension {
2324
$extension_name = $title
@@ -32,7 +33,7 @@
3233
command => "/root/.phpbrew/install_extension.sh ${php_version} ${extension_name} ${version}",
3334
timeout => 0,
3435
user => 'root',
35-
creates => "/opt/phpbrew/php/php-${php_version}/var/db/${extension_name}.ini",
36+
creates => "${install_dir}/php/php-${php_version}/var/db/${extension_name}.ini",
3637
notify => Service['httpd']
3738
}
3839
}

manifests/init.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# class { 'phpbrew': }
1313
#
1414
class phpbrew (
15-
15+
$php_install_dir = '/opt/phpbrew'
1616
) {
1717
case $operatingsystem {
1818
centos, redhat: {
@@ -61,14 +61,14 @@
6161
refreshonly => true,
6262
}
6363

64-
file { '/opt/phpbrew':
64+
file { $php_install_dir:
6565
ensure => 'directory',
6666
require => Exec['init phpbrew'],
6767
}
6868

6969
# Specify where versions of PHP will be installed.
7070
file { "/root/.phpbrew/init":
71-
content => 'export PHPBREW_ROOT=/opt/phpbrew',
71+
content => "export PHPBREW_ROOT=${php_install_dir}",
7272
require => Exec['init phpbrew']
7373
}
7474

manifests/install.pp

+35-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#
1717
define phpbrew::install(
1818
$version = '',
19-
$default_path = '/opt/phpbrew'
19+
$build_prameters = undef,
20+
$php_inis = undef,
21+
$install_dir = '/opt/phpbrew',
2022
) {
2123
require phpbrew
2224

@@ -26,15 +28,17 @@
2628
$php_version = $version
2729
}
2830

29-
if versioncmp($php_version, '5.3') < 0 {
30-
$extra_params = ''
31+
if $build_prameters {
32+
$extra_params = $build_prameters
33+
} elsif versioncmp($php_version, '5.3') < 0 {
34+
$extra_params = ''
3135
} else {
32-
$extra_params = ''
36+
$extra_params = ''
3337
}
3438

3539
exec { "install php-${php_version}":
36-
command => "sudo PHPBREW_ROOT=${$default_path} /usr/bin/phpbrew install --old php-${php_version} +default +intl +cgi ${extra_params}",
37-
creates => "${default_path}/php/php-${php_version}/bin/php",
40+
command => "sudo PHPBREW_ROOT=${install_dir} /usr/bin/phpbrew install --old php-${php_version} +default +intl +cgi ${extra_params}",
41+
creates => "${install_dir}/php/php-${php_version}/bin/php",
3842
timeout => 0,
3943
}
4044

@@ -44,4 +48,29 @@
4448
mode => 'a+x',
4549
require => Exec["install php-${php_version}"]
4650
}
51+
52+
file { "${install_dir}/php/php-${php_version}/lib/php/share":
53+
ensure => "directory",
54+
require => Exec["install php-${php_version}"]
55+
}
56+
57+
if $php_inis != undef {
58+
file { [
59+
"${install_dir}/php/php-${php_version}/var",
60+
"${install_dir}/php/php-${php_version}/var/db"
61+
]:
62+
ensure => "directory",
63+
require => Exec["install php-${php_version}"]
64+
}
65+
66+
each($php_inis) |$php_ini| {
67+
$short_php_ini = regsubst($php_ini, '^.*\/([^\/]*\.ini)$', '\1')
68+
69+
file { "${install_dir}/php/php-${php_version}/var/db/${short_php_ini}":
70+
source => $php_ini,
71+
require => File["${install_dir}/php/php-${php_version}/var/db"]
72+
}
73+
}
74+
}
75+
4776
}

templates/fcgiwrapper.sh.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export PHP_FCGI_CHILDREN
88
PHP_FCGI_MAX_REQUESTS=10000
99
export PHP_FCGI_MAX_REQUESTS
1010

11-
exec <%= @default_path %>/php/php-<%= @php_version %>/bin/php-cgi
11+
exec <%= @install_dir %>/php/php-<%= @php_version %>/bin/php-cgi

0 commit comments

Comments
 (0)