Skip to content

Commit 460a6a0

Browse files
author
Alexander Schneider
committed
Initial commit
0 parents  commit 460a6a0

File tree

9 files changed

+218
-0
lines changed

9 files changed

+218
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

Modulefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name 'phpbrew'
2+
version '1.0.0'
3+
author 'Jankowfsky AG - Alexander Schneider'
4+
description 'Puppet module for phpbrew.'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Puppet module for phpbrew.

files/install_extension.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
source /root/.phpbrew/bashrc
3+
phpbrew use $1
4+
phpbrew ext install $2 $3
5+
phpbrew off

manifests/extension.pp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Definition: phpbrew::extension
2+
#
3+
# This class installs the given extension for the given version
4+
#
5+
# Parameters:
6+
# - The $extension
7+
# - The $version the php version
8+
#
9+
# Actions:
10+
# - Install the given extension version
11+
#
12+
# Sample Usage:
13+
# phpbrew::extension { 'xdebug':
14+
# version => '5.3.28'
15+
# }
16+
#
17+
define phpbrew::extension(
18+
$extension = undef,
19+
$php_version = undef,
20+
$version = undef
21+
) {
22+
if ! $extension {
23+
$extension_name = $title
24+
} else {
25+
$extension_name = $extension
26+
}
27+
28+
if ! $php_version {
29+
warning('No version for extension given. Install aborted.')
30+
} else {
31+
exec { "phpbrew_extension_${extension_name}-${php_version}-${version}":
32+
command => "/root/.phpbrew/install_extension.sh ${php_version} ${extension_name} ${version}",
33+
timeout => 0,
34+
user => 'root',
35+
creates => "/opt/phpbrew/php/php-${php_version}/var/db/${extension_name}.ini",
36+
notify => Service['httpd']
37+
}
38+
}
39+
}

manifests/init.pp

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Class: phpbrew
2+
#
3+
# This module manages the installing of phpbrew.
4+
#
5+
# Parameters:
6+
#
7+
# Actions:
8+
#
9+
# Requires:
10+
# puppetlabs/stdlib
11+
# Sample Usage:
12+
# class { 'phpbrew': }
13+
#
14+
class phpbrew (
15+
$dependencies = undef
16+
) {
17+
case $operatingsystem {
18+
centos, redhat: {
19+
fail('CentOS or RedHat are not supported yet')
20+
}
21+
debian, ubuntu: {
22+
exec { '/usr/bin/apt-get -y update': }
23+
24+
if ! $dependencies {
25+
$neededDependencies = [ 'autoconf', 'automake', 'curl', 'build-essential', 'libxslt1-dev', 're2c', 'libxml2-dev', 'php5-cli', 'libmcrypt-dev' ]
26+
} else {
27+
$neededDependencies = $dependencies
28+
}
29+
30+
package { $neededDependencies:
31+
ensure => 'installed',
32+
require => Exec['/usr/bin/apt-get -y update'],
33+
before => Exec['download phpbrew'],
34+
}
35+
36+
exec { '/usr/bin/apt-get -y build-dep php5':
37+
require => Exec['/usr/bin/apt-get -y update'],
38+
before => Exec['download phpbrew'],
39+
}
40+
}
41+
default: {
42+
fail('Unrecognized operating system for phpbrew')
43+
}
44+
}
45+
46+
exec { 'download phpbrew':
47+
command => '/usr/bin/curl -o /tmp/phpbrew https://raw.github.com/c9s/phpbrew/master/phpbrew',
48+
creates => '/tmp/phpbrew',
49+
}
50+
51+
file { '/usr/bin/phpbrew':
52+
source => '/tmp/phpbrew',
53+
mode => 'a+x',
54+
require => Exec['download phpbrew'],
55+
}
56+
57+
exec { 'init phpbrew':
58+
command => 'sudo /usr/bin/phpbrew init',
59+
creates => "/root/.phpbrew/bashrc",
60+
subscribe => File['/usr/bin/phpbrew'],
61+
refreshonly => true,
62+
}
63+
64+
file { '/opt/phpbrew':
65+
ensure => 'directory',
66+
require => Exec['init phpbrew'],
67+
}
68+
69+
# Specify where versions of PHP will be installed.
70+
file { "/root/.phpbrew/init":
71+
content => 'export PHPBREW_ROOT=/opt/phpbrew',
72+
require => Exec['init phpbrew']
73+
}
74+
75+
# Load phpbrew configuration by default.
76+
file_line { 'add phpbrew to bashrc':
77+
path => '/root/.bashrc',
78+
line => "source /root/.phpbrew/bashrc",
79+
require => Exec['init phpbrew'],
80+
}
81+
82+
exec { 'update basbrc':
83+
command => "bash"
84+
}
85+
86+
file { "/root/.phpbrew/install_extension.sh":
87+
ensure => present,
88+
mode => 'a+x',
89+
source => "puppet:///modules/phpbrew/install_extension.sh",
90+
require => Exec['init phpbrew']
91+
}
92+
}

manifests/install.pp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Definition: phpbrew::install
2+
#
3+
# This class installs the given PHP version
4+
#
5+
# Parameters:
6+
# - The $version to install
7+
#
8+
# Actions:
9+
# - Install the given PHP version
10+
#
11+
# Requires:
12+
# - The phpbrew class
13+
#
14+
# Sample Usage:
15+
# phpbrew::install { '5.3.3': }
16+
#
17+
define phpbrew::install(
18+
$version = '',
19+
$default_path = '/opt/phpbrew'
20+
) {
21+
#require phpbrew
22+
23+
if $version == '' {
24+
$php_version = $title
25+
} else {
26+
$php_version = $version
27+
}
28+
29+
if versioncmp($php_version, '5.3') < 0 {
30+
$extra_params = ''
31+
} else {
32+
$extra_params = ''
33+
}
34+
35+
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",
38+
timeout => 0,
39+
}
40+
41+
file { "/usr/lib/cgi-bin/fcgiwrapper-${php_version}.sh":
42+
ensure => present,
43+
content => template("phpbrew/fcgiwrapper.sh.erb"),
44+
mode => 'a+x',
45+
require => Exec["install php-${php_version}"]
46+
}
47+
}

metadata.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"description": "Puppet module for phpbrew.",
3+
"summary": "UNKNOWN",
4+
"source": "UNKNOWN",
5+
"version": "1.0.0",
6+
"author": "Jankowfsky AG - Alexander Schneider",
7+
"dependencies": [
8+
9+
],
10+
"types": [
11+
12+
],
13+
"project_page": "http://github.com/GM-Alex/puppet-phpbrew",
14+
"license": "Apache License, Version 2.0",
15+
"checksums": {
16+
},
17+
"name": "phpbrew"
18+
}

templates/fcgiwrapper.sh.erb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
PHPRC=<%= @default_path %>/php/php-<%= @php_version %>/etc/php.ini
3+
export PHPRC
4+
5+
PHP_FCGI_CHILDREN=3
6+
export PHP_FCGI_CHILDREN
7+
8+
PHP_FCGI_MAX_REQUESTS=10000
9+
export PHP_FCGI_MAX_REQUESTS
10+
11+
exec <%= @default_path %>/php/php-<%= @php_version %>/bin/php-cgi

0 commit comments

Comments
 (0)