thias / puppet-php

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

Add priority as comment in header for debian #74

Open kronos-pbrideau opened 9 years ago

kronos-pbrideau commented 9 years ago

The phpenmod script use this comment... When php modules are upgraded via the package manager, it run this script and reenable script which look like not present for the system...

=== Example with mysqlnd === Debian create in with priority 10 when installing so it is linked as /etc/php5/cli/conf.d/10-mysqlnd.ini -> ../../mods-available/mysqlnd.ini

Then php puppet module replace mysqlnd.ini without the comment. (; priority=10)

When a package upgrade pass on debian 8, it goes: /usr/share/php5/php5-helper

get_priority() {
[...]
    local source_ini="/etc/php5/mods-available/${modname}.ini"
[...]
    priority=$(sed -ne "s/^; priority=\([0-9]\+\)$/\\1/p" $source_ini)
    [ -z "$priority" ] && priority=20
[...]

So default to priority=20

/usr/sbin/php5enmod

enmod() {
[...]
    local priority=$(get_priority $sapi $modname)
[...]

And create another /etc/php5/cli/conf.d/20-mysqlnd.ini -> ../../mods-available/mysqlnd.ini

So in the end, we have both and result in lots of warnings and errors:

/etc/php5/cli/conf.d/10-mysqlnd.ini -> ../../mods-available/mysqlnd.ini
/etc/php5/cli/conf.d/20-mysqlnd.ini -> ../../mods-available/mysqlnd.ini
thias commented 9 years ago

Interesting. Do you think it's worth merging somehow with the existing $prefix parameter, which is very similar? Could you at least make this conditionally enabled only on Debian systems? (I have no idea if it's also relevant to Ubuntu or not...)

kronos-pbrideau commented 9 years ago

Well, the $prefix variable is used to rename files in /etc/php5/mods-available/ as i see... They are needed when you want to set priority directly in your config file. (older debian config? redhat config? I don't know where, but i guess someone uses it?)

In Debian based, the files in /etc/php5/(apache2|fpm|cli)/conf.d/ are the one containing this priority bit, but they are not managed with the puppet module. They are symlinks to /mods-available, and created by the packages of the modules...

the module ::php::module { 'mysqlnd' : } install the package php5-mysqlnd and will create these files depending of what is installed on your system: /etc/php5/apache2/conf.d/10-mysqlnd.ini -> /etc/php5/mods-available/mysqlnd.ini /etc/php5/cli/conf.d/10-mysqlnd.ini -> /etc/php5/mods-available/mysqlnd.ini /etc/php5/fpm/conf.d/10-mysqlnd.ini -> /etc/php5/mods-available/mysqlnd.ini

Note the 10-mysqlnd.ini is not in /etc/php5/mod-available/ but (apache|fpm|cli)

If we use the $prefix variable to set this priority, we will end-up with an non-existing symlink, or worse, the file /etc/php5/mods-available/mysqlnd.ini created by the package manager, but not managed by ::php::module::ini { 'mysqlnd' : }

And yes, it is also relevant to Ubuntu.

a simple change like <% if @osfamily == 'Debian' and @priority -%> would be sufficient i guess