Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions manifests/extension/apc.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,41 @@
$version = '3.1.13'
) {
require php::config

# Current supported and secure versions
$secure_5_6 = $php::config::secure_versions['5.6']
$secure_5_5 = $php::config::secure_versions['5.5']
$secure_5_4 = $php::config::secure_versions['5.4']

# Specify secure version if no minor point specified
if $php == '5' {
$patch_version = $secure_5_6
} elsif $php == '5.6' {
$patch_version = $secure_5_6
} elsif $php == '5.5' {
$patch_version = $secure_5_5
} elsif $php == '5.4' {
$patch_version = $secure_5_4
} else {
$patch_version = $php
}

# Require php version eg. php::5_4_10
# This will compile, install and set up config dirs if not present
php_require($php)
php_require($patch_version)

$extension = 'apc'
$package_name = "APC-${version}"
$url = "http://pecl.php.net/get/APC-${version}.tgz"
if ($patch_version == '5.4') {
$extension = 'apc'
$package_name = "APC-${version}"
$url = "http://pecl.php.net/get/APC-${version}.tgz"
} else {
$extension = 'apcu'
$package_name = "APCu-${version}"
$url = "http://pecl.php.net/get/apcu-${version}.tgz"
}

# Final module install path
$module_path = "${php::config::root}/versions/${php}/modules/${extension}.so"
$module_path = "${php::config::root}/versions/${patch_version}/modules/${extension}.so"

php_extension { $name:
extension => $extension,
Expand All @@ -30,14 +55,14 @@
package_url => $url,
homebrew_path => $boxen::config::homebrewdir,
phpenv_root => $php::config::root,
php_version => $php,
php_version => $patch_version,
cache_dir => $php::config::extensioncachedir,
}

# Add config file once extension is installed

file { "${php::config::configdir}/${php}/conf.d/${extension}.ini":
content => template("php/extensions/${extension}.ini.erb"),
file { "${php::config::configdir}/${patch_version}/conf.d/${extension}.ini":
content => template("php/extensions/apc.ini.erb"),
require => Php_extension[$name],
}

Expand Down
24 changes: 21 additions & 3 deletions manifests/extension/intl.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@
) {
require php::config

# Current supported and secure versions
$secure_5_6 = $php::config::secure_versions['5.6']
$secure_5_5 = $php::config::secure_versions['5.5']
$secure_5_4 = $php::config::secure_versions['5.4']

# Specify secure version if no minor point specified
if $php == '5' {
$patch_version = $secure_5_6
} elsif $php == '5.6' {
$patch_version = $secure_5_6
} elsif $php == '5.5' {
$patch_version = $secure_5_5
} elsif $php == '5.4' {
$patch_version = $secure_5_4
} else {
$patch_version = $php
}

# Require php version eg. php::5_4_10
# This will compile, install and set up config dirs if not present
php_require($php)
Expand All @@ -22,7 +40,7 @@
$url = "http://pecl.php.net/get/intl-${version}.tgz"

# Final module install path
$module_path = "${php::config::root}/versions/${php}/modules/${extension}.so"
$module_path = "${php::config::root}/versions/${patch_version}/modules/${extension}.so"

# Additional options
$configure_params = "--with-icu-dir=${boxen::config::homebrewdir}/opt/icu4c"
Expand All @@ -34,14 +52,14 @@
package_url => $url,
homebrew_path => $boxen::config::homebrewdir,
phpenv_root => $php::config::root,
php_version => $php,
php_version => $patch_version,
cache_dir => $php::config::extensioncachedir,
configure_params => $configure_params,
}

# Add config file once extension is installed

file { "${php::config::configdir}/${php}/conf.d/${extension}.ini":
file { "${php::config::configdir}/${patch_version}/conf.d/${extension}.ini":
content => template('php/extensions/generic.ini.erb'),
require => Php_extension[$name],
}
Expand Down
27 changes: 23 additions & 4 deletions manifests/extension/xdebug.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,35 @@
$version = '2.2.1'
) {
require php::config

# Current supported and secure versions
$secure_5_6 = $php::config::secure_versions['5.6']
$secure_5_5 = $php::config::secure_versions['5.5']
$secure_5_4 = $php::config::secure_versions['5.4']

# Specify secure version if no minor point specified
if $php == '5' {
$patch_version = $secure_5_6
} elsif $php == '5.6' {
$patch_version = $secure_5_6
} elsif $php == '5.5' {
$patch_version = $secure_5_5
} elsif $php == '5.4' {
$patch_version = $secure_5_4
} else {
$patch_version = $php
}

# Require php version eg. php::5_4_10
# This will compile, install and set up config dirs if not present
php_require($php)
php_require($patch_version)

$extension = 'xdebug'
$package_name = "xdebug-${version}"
$url = "http://xdebug.org/files/xdebug-${version}.tgz"

# Final module install path
$module_path = "${php::config::root}/versions/${php}/modules/${extension}.so"
$module_path = "${php::config::root}/versions/${patch_version}/modules/${extension}.so"

php_extension { $name:
extension => $extension,
Expand All @@ -30,13 +49,13 @@
package_url => $url,
homebrew_path => $boxen::config::homebrewdir,
phpenv_root => $php::config::root,
php_version => $php,
php_version => $patch_version,
cache_dir => $php::config::extensioncachedir,
}

# Add config file once extension is installed

file { "${php::config::configdir}/${php}/conf.d/${extension}.ini":
file { "${php::config::configdir}/${patch_version}/conf.d/${extension}.ini":
content => template("php/extensions/${extension}.ini.erb"),
require => Php_extension[$name],
}
Expand Down
27 changes: 11 additions & 16 deletions manifests/fpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@
$bin = "${php::config::root}/versions/${patch_version}/sbin/php-fpm"

# Set up FPM config
file { $fpm_config:
ensure_resource('file', $fpm_config, {
content => template('php/php-fpm.conf.erb'),
notify => Php::Fpm::Service[$patch_version],
}
})

# Set up FPM Pool config directory
file { $fpm_pool_config_dir:
ensure_resource('file', $fpm_pool_config_dir, {
ensure => directory,
recurse => true,
force => true,
source => 'puppet:///modules/php/empty-conf-dir',
require => File[$version_config_root],
}
})

# Create a default pool, as FPM won't start without one
# Listen on a fake socket for now
Expand All @@ -72,33 +72,28 @@
$min_spare_servers = 1
$max_spare_servers = 1

file { "${fpm_pool_config_dir}/${patch_version}.conf":
ensure_resource('file', "${fpm_pool_config_dir}/${patch_version}.conf", {
content => template('php/php-fpm-pool.conf.erb'),
}
})

# Launch our FPM Service

php::fpm::service{ $patch_version:
ensure_resource('php::fpm::service', $patch_version, {
ensure => running,
subscribe => File["${fpm_pool_config_dir}/${patch_version}.conf"],
}
})

} else {

# Stop service and kill configs
# Stop service first as we need to unload the plist file

file { [
$fpm_config,
$fpm_pool_config_dir,
]:
ensure_resource('file', [$fpm_config,$fpm_pool_config_dir], {
ensure => absent,
require => Php::Fpm::Service[$patch_version],
}
})

php::fpm::service{ $patch_version:
ensure => absent,
}
ensure_resource('php::fpm::service', $patch_version, { ensure => absent })
}

}
24 changes: 21 additions & 3 deletions manifests/fpm/pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,41 @@
) {
require php::config

# Current supported and secure versions
$secure_5_6 = $php::config::secure_versions['5.6']
$secure_5_5 = $php::config::secure_versions['5.5']
$secure_5_4 = $php::config::secure_versions['5.4']

# Specify secure version if no minor point specified
if $version == '5' {
$patch_version = $secure_5_6
} elsif $version == '5.6' {
$patch_version = $secure_5_6
} elsif $version == '5.5' {
$patch_version = $secure_5_5
} elsif $version == '5.4' {
$patch_version = $secure_5_4
} else {
$patch_version = $version
}

# Set config

$fpm_pool_config_dir = "${php::config::configdir}/${version}/pool.d"
$fpm_pool_config_dir = "${php::config::configdir}/${patch_version}/pool.d"
$pool_name = join(split($name, '[. ]'), '_')

# Set up PHP-FPM pool

if $ensure == present {
# Ensure that the php fpm service for this php version is installed
# eg. php::fpm::5_4_10
php_fpm_require $version
php_fpm_require $patch_version

# Create a pool config file
file { "${fpm_pool_config_dir}/${pool_name}.conf":
content => template($fpm_pool),
require => File[$fpm_pool_config_dir],
notify => Service["dev.php-fpm.${version}"],
notify => Service["dev.php-fpm.${patch_version}"],
}
}
}
24 changes: 18 additions & 6 deletions manifests/global.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,32 @@
class php::global($version = undef) {
include php::config

# Default to latest version of PHP 5 if not specified
$php_version = $version ? {
undef => 5,
default => $version
# Current supported and secure versions
$secure_5_6 = $php::config::secure_versions['5.6']
$secure_5_5 = $php::config::secure_versions['5.5']
$secure_5_4 = $php::config::secure_versions['5.4']

# Specify secure version if no minor point specified
if $version == '5' {
$php_version = $secure_5_6
} elsif $version == '5.6' {
$php_version = $secure_5_6
} elsif $version == '5.5' {
$php_version = $secure_5_5
} elsif $version == '5.4' {
$php_version = $secure_5_4
} else {
$php_version = $version
}

if $version != 'system' {
php_require($version)
php_require($php_version)
}

file { "${php::config::root}/version":
ensure => present,
owner => $::boxen_user,
mode => '0644',
content => "${version}\n",
content => "${php_version}\n",
}
}
27 changes: 23 additions & 4 deletions manifests/project.pp
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,41 @@
}

if $php {

# Current supported and secure versions
$secure_5_6 = $php::config::secure_versions['5.6']
$secure_5_5 = $php::config::secure_versions['5.5']
$secure_5_4 = $php::config::secure_versions['5.4']

# Specify secure version if no minor point specified
if $php == '5' {
$php_version = $secure_5_6
} elsif $php == '5.6' {
$php_version = $secure_5_6
} elsif $php == '5.5' {
$php_version = $secure_5_5
} elsif $php == '5.4' {
$php_version = $secure_5_4
} else {
$php_version = $php
}

# Set the local version of PHP
php::local { $repo_dir:
version => $php,
version => $php_version,
require => Repository[$repo_dir],
}

# Spin up a PHP-FPM pool for this project, listening on an Nginx socket
php::fpm::pool { "${name}-${php}":
version => $php,
php::fpm::pool { "${name}-${php_version}":
version => $php_version,
socket_path => "${boxen::config::socketdir}/${name}",
require => File["${nginx::config::sitesdir}/${name}.conf"],
max_children => 10,
}

if $fpm_pool {
Php::Fpm::Pool["${name}-${php}"] {
Php::Fpm::Pool["${name}-${php_version}"] {
fpm_pool => $fpm_pool
}
}
Expand Down
Loading