Skip to content

Commit

Permalink
Merge 83c85bf into a87005f
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrodala committed Nov 30, 2016
2 parents a87005f + 83c85bf commit 4337e18
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 8 deletions.
22 changes: 14 additions & 8 deletions manifests/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,30 @@
require => $package_depends,
}

# Ubuntu/Debian systems use the mods-available folder. We need to enable
# settings files ourselves with php5enmod command.
# Ubuntu/Debian systems use the mods-available folder. We need to handle
# settings files ourselves with CLI commands.
$ext_tool_enable = pick_default($::php::ext_tool_enable, $::php::params::ext_tool_enable)
$ext_tool_disable = pick_default($::php::ext_tool_disable, $::php::params::ext_tool_disable)
$ext_tool_query = pick_default($::php::ext_tool_query, $::php::params::ext_tool_query)
$ext_tool_enabled = pick_default($::php::ext_tool_enabled, $::php::params::ext_tool_enabled)
$final_sapi = $sapi ? {
'ALL' => 'cli',
default => $sapi,
}

if $::osfamily == 'Debian' and $ext_tool_enabled {
$cmd = "${ext_tool_enable} -s ${sapi} ${lowercase_title}"
if $ensure == 'absent' {
$cmd = "${ext_tool_disable} -s ${final_sapi} ${lowercase_title}"

if $sapi == 'ALL' {
exec { $cmd:
onlyif => "${ext_tool_query} -s cli -m ${lowercase_title} | /bin/grep 'No module matches ${lowercase_title}'",
require =>::Php::Config[$title],
unless => "${ext_tool_query} -s ${final_sapi} -m ${lowercase_title} | /bin/grep 'No module matches ${lowercase_title}'",
}
} else {
$cmd = "${ext_tool_enable} -s ${final_sapi} ${lowercase_title}"

exec { $cmd:
onlyif => "${ext_tool_query} -s ${sapi} -m ${lowercase_title} | /bin/grep 'No module matches ${lowercase_title}'",
require =>::Php::Config[$title],
onlyif => "${ext_tool_query} -s ${final_sapi} -m ${lowercase_title} | /bin/grep 'No module matches ${lowercase_title}'",
require => ::Php::Config[$title],
}
}

Expand Down
5 changes: 5 additions & 0 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
$fpm_error_log = '/var/log/php5-fpm.log'
$fpm_service_name = 'php5-fpm'
$ext_tool_enable = '/usr/sbin/php5enmod'
$ext_tool_disable = '/usr/sbin/php5dismod'
$ext_tool_query = '/usr/sbin/php5query'
$package_prefix = 'php5-'
}
Expand All @@ -59,6 +60,7 @@
$fpm_error_log = "/var/log/php${globals_php_version}-fpm.log"
$fpm_service_name = "php${globals_php_version}-fpm"
$ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}"
$ext_tool_disable = "/usr/sbin/phpdismod -v ${globals_php_version}"
$ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}"
$package_prefix = "php${globals_php_version}-"
}
Expand All @@ -70,6 +72,7 @@
$fpm_error_log = '/var/log/php5-fpm.log'
$fpm_service_name = 'php5-fpm'
$ext_tool_enable = '/usr/sbin/php5enmod'
$ext_tool_disable = '/usr/sbin/php5dismod'
$ext_tool_query = '/usr/sbin/php5query'
$package_prefix = 'php5-'
}
Expand All @@ -82,6 +85,7 @@
$fpm_error_log = "/var/log/php${globals_php_version}-fpm.log"
$fpm_service_name = "php${globals_php_version}-fpm"
$ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}"
$ext_tool_disable = "/usr/sbin/phpdismod -v ${globals_php_version}"
$ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}"
$package_prefix = 'php7.0-'
}
Expand All @@ -91,6 +95,7 @@
$fpm_error_log = '/var/log/php5-fpm.log'
$fpm_service_name = 'php5-fpm'
$ext_tool_enable = '/usr/sbin/php5enmod'
$ext_tool_disable = '/usr/sbin/php5dismod'
$ext_tool_query = '/usr/sbin/php5query'
$package_prefix = 'php5-'
}
Expand Down
8 changes: 8 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
# Absolute path to php tool for enabling extensions in debian/ubuntu systems.
# This defaults to '/usr/sbin/php5enmod'.
#
# [*ext_tool_disable*]
# Absolute path to php tool for disabling extensions in debian/ubuntu systems.
# This defaults to '/usr/sbin/php5dismod'.
#
# [*ext_tool_query*]
# Absolute path to php tool for querying information about extensions in
# debian/ubuntu systems. This defaults to '/usr/sbin/php5query'.
Expand Down Expand Up @@ -130,6 +134,7 @@
$package_prefix = $::php::params::package_prefix,
$config_root_ini = $::php::params::config_root_ini,
$ext_tool_enable = $::php::params::ext_tool_enable,
$ext_tool_disable = $::php::params::ext_tool_disable,
$ext_tool_query = $::php::params::ext_tool_query,
$ext_tool_enabled = $::php::params::ext_tool_enabled,
$log_owner = $::php::params::fpm_user,
Expand Down Expand Up @@ -161,6 +166,9 @@
if $ext_tool_enable != undef {
validate_absolute_path($ext_tool_enable)
}
if $ext_tool_disable != undef {
validate_absolute_path($ext_tool_disable)
}
if $ext_tool_query != undef {
validate_absolute_path($ext_tool_query)
}
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
$compiler_packages = 'build-essential'
$root_group = 'root'
$ext_tool_enable = $php::globals::ext_tool_enable
$ext_tool_disable = $php::globals::ext_tool_disable
$ext_tool_query = $php::globals::ext_tool_query
$ext_tool_enabled = true

Expand Down
23 changes: 23 additions & 0 deletions spec/defines/extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,29 @@
it { is_expected.to contain_php__config('xdebug').with_config('zend_extension' => '/usr/lib/php5/20100525/xdebug.so') }
end

context 'enable extension' do
let(:title) { 'xdebug' }
let(:params) do
{
zend: true,
}
end

it { is_expected.to contain_exec('/usr/sbin/php5enmod -s ALL xdebug') }
end

context 'disable extension' do
let(:title) { 'xdebug' }
let(:params) do
{
ensure: 'absent',
zend: true,
}
end

it { is_expected.to contain_exec('/usr/sbin/php5dismod -s ALL xdebug') }
end

case facts[:osfamily]
when 'Debian'
context 'on Debian' do
Expand Down

0 comments on commit 4337e18

Please sign in to comment.