thias / puppet-php

Puppet module to manage PHP
Other
49 stars 67 forks source link

'20-apc.ini' formatted ini files #32

Open basvanmeurs opened 10 years ago

basvanmeurs commented 10 years ago

On debian, the ini files are named as '20-apc.ini' (they have a priority number).

When using your module, files are always created as 'apc.ini' and there is no way to change this.

Example: php::module::ini { 'apc': settings => { 'apc.enabled' => '1', 'apc.shm_segments' => '1', 'apc.shm_size' => '128M', } }

Produces '/etc/php5/conf.d/apc.ini'. Installing packaging php-apc already produced the file '/etc/php5/conf.d/20-apc.ini' with just the following line: extension=apc.so

Netto effect: 2 files in the config directory and messages such as "PHP Warning: Module 'apc' already loaded in Unknown on line 0" when running the php command.

Proposed solution: allow to specify the output ini filename.

basvanmeurs commented 10 years ago

Patch on master branch (patch-php_module_ini-filename-param.diff):

diff --git a/manifests/module/ini.pp b/manifests/module/ini.pp
old mode 100644
new mode 100755
index 9069781..ea53f4e
--- a/manifests/module/ini.pp
+++ b/manifests/module/ini.pp
@@ -19,6 +19,7 @@ define php::module::ini (
   $pkgname  = false,
   $settings = {},
   $zend     = false,
+  $filename = "${title}.ini",
 ) {

   include '::php::params'
@@ -42,11 +43,11 @@ define php::module::ini (

   # INI configuration file
   if $ensure == 'absent' {
-    file { "${::php::params::php_conf_dir}/${modname}.ini":
+    file { "${::php::params::php_conf_dir}/${filename}":
       ensure => absent,
     }
   } else {
-    file { "${::php::params::php_conf_dir}/${modname}.ini":
+    file { "${::php::params::php_conf_dir}/${filename}":
       ensure  => $ensure,
       require => Package[$ospkgname],
       content => template('php/module.ini.erb'),
thias commented 10 years ago

Are most/many files using a single prefix number? Because it could be simpler if params.pp specified that default prefix for Debian, with the ability to override it when a different value is needed, and disabled the feature for RedHat.

basvanmeurs commented 10 years ago

Hi thias, it is not a fixed prefix. The number indicates the priority so has a meaning. See http://superuser.com/questions/564995/what-is-the-php-config-ini-files-prefix-good-for for some more info.

3flex commented 10 years ago

Hi @basvanmeurs, which version of Debian are you using? According to the file list for php-apc package, on squeeze the file path is /etc/php5/conf.d/apc.ini and wheezy it is /etc/php5/mods-available/apc.ini.

See https://packages.debian.org/squeeze/amd64/php-apc/filelist and https://packages.debian.org/wheezy/amd64/php-apc/filelist

jshholland commented 10 years ago

@3flex the prefix is added when the ini file is symlinked in by the /usr/sbin/php5enmod script (here), which is run after installation. Thus it doesn't show up in the filelist, but is added by the package after install.