This repository has been archived by the owner on Oct 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Mix and match various proposals. * Parameters classes must be included. refs #142 * Added doc blox and assert_private. refs #148
- Loading branch information
Showing
3 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,15 @@ | |
# [*source*] | ||
# The path to the deb package to install | ||
# | ||
# [*sapis*] | ||
# An array of PHP SAPIs for which extension should be installed. This | ||
# parameters applies to PECL extensions only. | ||
# @see http://php.net/manual/en/function.php-sapi-name.php | ||
# | ||
# [*priority*] | ||
# Module loading priority. Default is 20. . | ||
# @see http://www.brandonchecketts.com/archives/getting-ubuntu-14-04-php5enmod-to-understand-module-priority | ||
# | ||
# === Variables | ||
# | ||
# [*php_ensure*] | ||
|
@@ -49,6 +58,14 @@ | |
# source => "/path/to/libgearman8_1.1.7-1_amd64.deb"; | ||
# } | ||
# | ||
# php::extension { 'gearman': | ||
# ensure => "latest", | ||
# package => "gearman", | ||
# provider => "pecl", | ||
# sapis => ['cli', 'fpm'], | ||
# priority_=> 30 | ||
# } | ||
# | ||
# === Authors | ||
# | ||
# Christian "Jippi" Winther <[email protected]> | ||
|
@@ -62,7 +79,9 @@ | |
$package, | ||
$provider = undef, | ||
$pipe = undef, | ||
$source = undef | ||
$source = undef, | ||
$sapis = ['cli', 'fpm', 'apache2'], | ||
$priority = 20, | ||
) { | ||
|
||
if $provider == 'pecl' { | ||
|
@@ -72,6 +91,13 @@ | |
source => $source, | ||
pipe => $pipe; | ||
} | ||
$uniqe_sapis = suffix($sapis, $package) | ||
php::sapi { $uniqe_sapis: | ||
extension => $package, | ||
ensure => $ensure, | ||
priority => $priority, | ||
require => Package[$package], | ||
} | ||
} elsif $provider == 'dpkg' { | ||
package { $package: | ||
ensure => $ensure, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# == Type: php::extension::disenable | ||
# | ||
# Enables a PHP extension installed using PECL | ||
# | ||
# === Parameters | ||
# | ||
# [*extension*] | ||
# The name of extension to enable or disenable | ||
# | ||
# [*ensure*] | ||
# The ensure of the package to install | ||
# Could be "latest", "installed", pinned version or "absent" | ||
# | ||
# [*priority*] | ||
# Integer indicateing loading order | ||
# | ||
# === Variables | ||
# | ||
# No variables | ||
# | ||
# === Examples | ||
# | ||
# This is a private type and should not be used on its own. | ||
# | ||
# === Author | ||
# | ||
# Goran Miskovic <[email protected]> | ||
# | ||
# === Copyright | ||
# | ||
# Copyright 2012-2016 Christian "Jippi" Winther, unless otherwise noted. | ||
# | ||
define php::extension::disenable ( | ||
$extension, | ||
$ensure = 'present', | ||
$priority = 20, | ||
) { | ||
|
||
assert_private("This is a privete type and should not be used on its own.") | ||
|
||
$sapi = delete($title, $extension) | ||
|
||
Exec { | ||
# fact that php5-common does not guarantee that extension is installed | ||
require => Package[$extension], | ||
# default path minus games | ||
path => '/bin:/usr/bin:/usr/local/bin: /sbin:/usr/sbin:/usr/local/sbin', | ||
} | ||
|
||
validate_re($ensure, '^(latest|present|installed|absent)$') | ||
# no need for qualified since path is defined | ||
$command = $ensure ? { | ||
'absent' => 'php5dismod', | ||
default => 'php5enmod' | ||
} | ||
# same as above | ||
$unless = $ensure ? { | ||
'absent' => 'test ! -e', | ||
default => 'test -e', | ||
} | ||
# regex is idempotent. no changes will be made if there is a space after semicolon already | ||
exec { "priority_${sapi}_${extension}": | ||
command => "sed -ie 's/^;priority/; priority/g' /etc/php5/mods-available/${extension}.ini", | ||
onlyif => "test -e /etc/php5/mods-available/${extension}.ini", | ||
} | ||
# extension class should be responsible for service notification | ||
exec { "${command} -s ${sapi} ${extension}": | ||
unless => "${unless} /etc/php5/${sapi}/conf.d/${priority}-${extension}.ini", | ||
require => Exec["priority_${sapi}_${extension}"] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# == Type: php::sapi | ||
# | ||
# Enables a PHP extension installed using PECL | ||
# | ||
# === Parameters | ||
# | ||
# [*extension*] | ||
# The name of extension to enable or disenable | ||
# | ||
# [*ensure*] | ||
# The ensure of the package to install | ||
# Could be "latest", "installed", pinned version or "absent" | ||
# | ||
# [*priority*] | ||
# Integer indicateing loading order | ||
# | ||
# === Variables | ||
# | ||
# No variables | ||
# | ||
# === Examples | ||
# | ||
# This is a private type and should not be used on its own. | ||
# | ||
# === Author | ||
# | ||
# Goran Miskovic <[email protected]> | ||
# | ||
# === Copyright | ||
# | ||
# Copyright 2012-2016 Christian "Jippi" Winther, unless otherwise noted. | ||
# | ||
define php::sapi ( | ||
$extension, | ||
$ensure, | ||
$priority, | ||
) { | ||
assert_private("This is a privete type and should not be used on its own.") | ||
include php::apache::params | ||
include php::fpm::params | ||
case $title { | ||
"fpm${extension}": { | ||
if defined(Service[$php::fpm::params::service_name]) { | ||
$disenable = $title | ||
} | ||
} | ||
"apache2${extension}": { | ||
if defined(Package[$php::apache::params::package]) { | ||
$disenable = $title | ||
} | ||
} | ||
"cli${extension}": { | ||
$disenable = $title | ||
} | ||
default: {} | ||
} | ||
|
||
unless empty($disenable) { | ||
php::extension::disenable { $disenable: | ||
extension => $extension, | ||
ensure => $ensure, | ||
priority => $priority, | ||
} | ||
} | ||
} |