Skip to content
This repository was archived by the owner on Oct 11, 2018. It is now read-only.
Merged
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
28 changes: 27 additions & 1 deletion manifests/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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*]
Expand All @@ -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]>
Expand All @@ -62,7 +79,9 @@
$package,
$provider = undef,
$pipe = undef,
$source = undef
$source = undef,
$sapis = ['cli', 'fpm', 'apache2'],
$priority = 20,
) {

if $provider == 'pecl' {
Expand All @@ -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,
Expand Down
72 changes: 72 additions & 0 deletions manifests/extension/disenable.pp
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}"]
}

}
65 changes: 65 additions & 0 deletions manifests/sapi.pp
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,
}
}
}