diff --git a/lib/facter/php_extension_dir.rb b/lib/facter/php_extension_dir.rb new file mode 100644 index 0000000..1ca82c3 --- /dev/null +++ b/lib/facter/php_extension_dir.rb @@ -0,0 +1,15 @@ +# Gets the directory where PHP modules are stored. Requires PHP +# to be installed. +Facter.add("php_extension_dir") do + setcode do + if File.exist? "/usr/bin/php" + Facter::Util::Resolution.exec('php -r "echo ini_get(\'extension_dir\');"') + else + if Facter.value("architecture") == "x86_64" + "/usr/lib64/php/modules" + else + "/usr/lib/php/modules" + end + end + end +end \ No newline at end of file diff --git a/manifests/module/ini.pp b/manifests/module/ini.pp index 20396c2..773faa4 100644 --- a/manifests/module/ini.pp +++ b/manifests/module/ini.pp @@ -13,7 +13,12 @@ # } # } # php::module::ini { 'xmlwriter': ensure => absent } -# +# php::module::ini { 'pecl-xdebug': +# zend => true, +# settings => { +# 'xdebug.remote_enable' => '1', +# } +# } define php::module::ini ( $pkgname = false, $settings = {}, @@ -30,12 +35,18 @@ default => "php-${pkgname}", } + # Extension directory where modules are located + $zend_path = $zend ? { + true => $php::params::extension_dir, + false => '', + default => $zend, + } + # INI configuration file file { "/etc/php.d/${modname}.ini": ensure => $ensure, require => Package[$rpmpkgname], content => template('php/module.ini.erb'), } - } diff --git a/manifests/params.pp b/manifests/params.pp index 27f8487..9cbc256 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -28,6 +28,10 @@ $httpd_package_name = 'httpd' $httpd_service_name = 'httpd' $httpd_conf_dir = '/etc/httpd/conf.d' + $extension_dir = "$::php_extension_dir" ? { + '' => '/usr/lib64/php/modules', + default => "$::php_extension_dir", + } } } } diff --git a/templates/module.ini.erb b/templates/module.ini.erb index a46ebeb..2544be3 100644 --- a/templates/module.ini.erb +++ b/templates/module.ini.erb @@ -1,7 +1,7 @@ ; NOTICE : File auto-generated by puppet, do not edit ; Enable <%= @modname %> extension module <% if @zend -%> -zend_extension=<%= @zend %>/<%= @modname %>.so +zend_extension=<%= @zend_path %>/<%= @modname %>.so <% else -%> extension=<%= @modname %>.so <% end -%>