Skip to content

Automatically detect PHP extension directory #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions lib/facter/php_extension_dir.rb
Original file line number Diff line number Diff line change
@@ -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
15 changes: 13 additions & 2 deletions manifests/module/ini.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {},
Expand All @@ -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'),
}

}

4 changes: 4 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}
}
}
2 changes: 1 addition & 1 deletion templates/module.ini.erb
Original file line number Diff line number Diff line change
@@ -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 -%>
Expand Down