diff --git a/manifests/extension.pp b/manifests/extension.pp index 53ca6603..10878a49 100644 --- a/manifests/extension.pp +++ b/manifests/extension.pp @@ -1,4 +1,4 @@ -# == Class: php::extension +# == Define php::extension # # Install a PHP extension package # @@ -58,30 +58,54 @@ # Copyright 2012-2015 Christian "Jippi" Winther, unless otherwise noted. # define php::extension( - $ensure, - $package, + $ensure = 'present', + $package = undef, $provider = undef, $pipe = undef, - $source = undef + $source = undef, + $extension = $title, + $priority = 20, ) { - if $provider == 'pecl' { + validate_re($ensure, '^(present|installed|absent)$') + $command = $ensure ? { + 'absent' => '/usr/sbin/php5dismod', + default => '/usr/sbin/php5enmod', + } + $unless = $ensure ? { + 'absent' => '/usr/bin/test ! -e', + default => '/usr/bin/test -e', + } + + if $package { package { $package: ensure => $ensure, provider => $provider, source => $source, pipe => $pipe; } - } elsif $provider == 'dpkg' { - package { $package: - ensure => $ensure, - provider => $provider, - source => $source; + } + + Exec { + require => Package['php5-common'], + path => '/bin:/usr/bin:/usr/local/bin', + } + + exec { "${command} -s cli ${extension}": + unless => "${unless} /etc/php5/cli/conf.d/${priority}-${extension}.ini", + } + + if $::php::params::service_name and defined(Service[$php::fpm::params::service_name]) { + exec { "${command} -s fpm ${extension}": + unless => "${unless} /etc/php5/fpm/conf.d/${priority}-${extension}.ini", + notify => Service[$php::fpm::params::service_name], } - } else { - package { $package: - ensure => $ensure, - provider => $provider; + } + + if $::php::apache::params::package and defined(Package[$php::apache::params::package]) { + exec { "${command} -s apache2 ${extension}": + unless => "${unless} /etc/php5/apache2/conf.d/${priority}-${extension}.ini", + notify => Service[$php::apache::params::service_name], } } diff --git a/manifests/extension/mysql.pp b/manifests/extension/mysql.pp index bb3432f6..d4bd9465 100644 --- a/manifests/extension/mysql.pp +++ b/manifests/extension/mysql.pp @@ -18,10 +18,17 @@ # [*inifile*] # The path to the extension ini file # +# [*pdo_inifile*] +# The path to the pdo extension ini file +# # [*settings*] # Hash with 'set' nested hash of key => value # set changes to agues when applied to *inifile* # +# [*pdo_settings*] +# Hash with 'set' nested hash of key => value +# set changes to agues when applied to *pdo_inifile* +# # === Variables # # No variables @@ -39,11 +46,15 @@ # Copyright 2012-2015 Christian "Jippi" Winther, unless otherwise noted. # class php::extension::mysql( - $ensure = $php::extension::mysql::params::ensure, - $package = $php::extension::mysql::params::package, - $provider = $php::extension::mysql::params::provider, - $inifile = $php::extension::mysql::params::inifile, - $settings = $php::extension::mysql::params::settings, + $ensure = $php::extension::mysql::params::ensure, + $package = $php::extension::mysql::params::package, + $provider = $php::extension::mysql::params::provider, + $inifile = $php::extension::mysql::params::inifile, + $pdo_inifile = $php::extension::mysql::params::pdo_inifile, + $settings = $php::extension::mysql::params::settings, + $pdo_settings = $php::extension::mysql::params::pdo_settings, + $mysqli_settings = $php::extension::mysql::params::settings, + $mysqli_settings = $php::extension::mysql::params::mysqli_inifile, ) inherits php::extension::mysql::params { php::extension { 'mysql': @@ -56,5 +67,13 @@ file => $inifile, config => $settings } + php::config { 'php-extension-pdo_mysql': + file => $pdo_inifile, + config => $pdo_settings + } + php::config { 'php-extension-mysqli': + file => $mysqli_inifile, + config => $mysqli_settings + } } diff --git a/manifests/extension/mysql/params.pp b/manifests/extension/mysql/params.pp index 574e66a8..2c560992 100644 --- a/manifests/extension/mysql/params.pp +++ b/manifests/extension/mysql/params.pp @@ -22,10 +22,17 @@ # [*inifile*] # The path to the extension ini file # +# [*pdo_inifile*] +# The path to the pdo extension ini file +# # [*settings*] # Hash with 'set' nested hash of key => value # set changes to agues when applied to *inifile* # +# [*pdo_settings*] +# Hash with 'set' nested hash of key => value +# set changes to agues when applied to *pod_inifile* +# # === Examples # # No examples @@ -40,10 +47,15 @@ # class php::extension::mysql::params { - $ensure = $php::params::ensure - $package = 'php5-mysql' - $provider = undef - $inifile = "${php::params::config_root_ini}/mysql.ini" - $settings = [ ] + $ensure = $php::params::ensure + $package = 'php5-mysql' + $provider = undef + $inifile = "${php::params::config_root_ini}/mysql.ini" + # these files the same for all mysql providers! + $pdo_inifile = "${php::params::config_root_ini}/pdo_mysql.ini" + $mysqli_inifile = "${php::params::config_root_ini}/mysqli.ini" + $settings = [ ] + $pdo_settings = [ ] + $mysqli_settings = [ ] } diff --git a/manifests/extension/mysqlnd.pp b/manifests/extension/mysqlnd.pp index 85edede9..6c673a3a 100644 --- a/manifests/extension/mysqlnd.pp +++ b/manifests/extension/mysqlnd.pp @@ -18,10 +18,17 @@ # [*inifile*] # The path to the extension ini file # +# [*pdo_inifile*] +# The path to the pdo extension ini file +# # [*settings*] # Hash with 'set' nested hash of key => value # set changes to agues when applied to *inifile* # +# [*pdo_settings*] +# Hash with 'set' nested hash of key => value +# set changes to agues when applied to *pdo_inifile* +# # === Variables # # No variables @@ -39,22 +46,30 @@ # Copyright 2012-2015 Christian "Jippi" Winther, unless otherwise noted. # class php::extension::mysqlnd( - $ensure = $php::extension::mysqlnd::params::ensure, - $package = $php::extension::mysqlnd::params::package, - $provider = $php::extension::mysqlnd::params::provider, - $inifile = $php::extension::mysqlnd::params::inifile, - $settings = $php::extension::mysqlnd::params::settings, + $ensure = $php::extension::mysqlnd::params::ensure, + $package = $php::extension::mysqlnd::params::package, + $provider = $php::extension::mysqlnd::params::provider, + $inifile = $php::extension::mysqlnd::params::inifile, + $pdo_inifile = $php::extension::mysqlnd::params::pdo_inifile, + $settings = $php::extension::mysqlnd::params::settings, + $pdo_settings = $php::extension::mysqlnd::params::pdo_settings, + $mysqli_settings = $php::extension::mysqlnd::params::settings, + $mysqli_settings = $php::extension::mysqlnd::params::mysqli_inifile, ) inherits php::extension::mysqlnd::params { php::extension { 'mysqlnd': ensure => $ensure, package => $package, - provider => $provider + provider => $provider, + priority => 10, } php::config { 'php-extension-mysqlnd': file => $inifile, config => $settings } - + php::config { 'php-extension-pdo_mysql': + file => $pdo_inifile, + config => $pdo_settings + } } diff --git a/manifests/extension/mysqlnd/params.pp b/manifests/extension/mysqlnd/params.pp index 4f2a8ae7..7b2bca99 100644 --- a/manifests/extension/mysqlnd/params.pp +++ b/manifests/extension/mysqlnd/params.pp @@ -22,10 +22,17 @@ # [*inifile*] # The path to the extension ini file # +# [*pdo_inifile*] +# The path to the pdo extension ini file +# # [*settings*] # Hash with 'set' nested hash of key => value # set changes to agues when applied to *inifile* # +# [*pdo_settings*] +# Hash with 'set' nested hash of key => value +# set changes to agues when applied to *pod_inifile* +# # === Examples # # No examples @@ -40,10 +47,15 @@ # class php::extension::mysqlnd::params { - $ensure = $php::params::ensure - $package = 'php5-mysqlnd' - $provider = undef - $inifile = "${php::params::config_root_ini}/mysqlnd.ini" - $settings = [ ] + $ensure = $php::params::ensure + $package = 'php5-mysqlnd' + $provider = undef + $inifile = "${php::params::config_root_ini}/mysqlnd.ini" + # these files the same for all mysql providers! + $pdo_inifile = "${php::params::config_root_ini}/pdo_mysql.ini" + $mysqli_inifile = "${php::params::config_root_ini}/mysqli.ini" + $settings = [ ] + $pdo_settings = [ ] + $mysqli_settings = [ ] } diff --git a/manifests/extension/pgsql.pp b/manifests/extension/pgsql.pp index a7291ab6..0388bd87 100644 --- a/manifests/extension/pgsql.pp +++ b/manifests/extension/pgsql.pp @@ -18,10 +18,17 @@ # [*inifile*] # The path to the extension ini file # +# [*pdo_inifile*] +# The path to the pdo extension ini file +# # [*settings*] # Hash with 'set' nested hash of key => value # set changes to agues when applied to *inifile* # +# [*pdo_settings*] +# Hash with 'set' nested hash of key => value +# set changes to agues when applied to *pdo_inifile* +# # === Variables # # No variables @@ -39,11 +46,13 @@ # Copyright 2012-2015 Nodes, unless otherwise noted. # class php::extension::pgsql( - $ensure = $php::extension::pgsql::params::ensure, - $package = $php::extension::pgsql::params::package, - $provider = $php::extension::pgsql::params::provider, - $inifile = $php::extension::pgsql::params::inifile, - $settings = $php::extension::pgsql::params::settings, + $ensure = $php::extension::pgsql::params::ensure, + $package = $php::extension::pgsql::params::package, + $provider = $php::extension::pgsql::params::provider, + $inifile = $php::extension::pgsql::params::inifile, + $pdo_inifile = $php::extension::pgsql::params::pdo_inifile, + $settings = $php::extension::pgsql::params::settings, + $pdo_settings = $php::extension::pgsql::params::pdo_settings, ) inherits php::extension::pgsql::params { php::extension { 'pgsql': @@ -56,4 +65,8 @@ file => $inifile, config => $settings } + php::config { 'php-extension-pdo_pgsql': + file => $pdo_inifile, + config => $pdo_settings + } } diff --git a/manifests/extension/pgsql/params.pp b/manifests/extension/pgsql/params.pp index e93a37d6..69472c47 100644 --- a/manifests/extension/pgsql/params.pp +++ b/manifests/extension/pgsql/params.pp @@ -22,10 +22,17 @@ # [*inifile*] # The path to the extension ini file # +# [*pdo_inifile*] +# The path to the pdo extension ini file +# # [*settings*] # Hash with 'set' nested hash of key => value # set changes to agues when applied to *inifile* # +# [*pdo_settings*] +# Hash with 'set' nested hash of key => value +# set changes to agues when applied to *pod_inifile* +# # === Examples # # No examples @@ -40,9 +47,11 @@ # class php::extension::pgsql::params { - $ensure = $php::params::ensure - $package = 'php5-pgsql' - $provider = undef - $inifile = "${php::params::config_root_ini}/pgsql.ini" - $settings = [ ] + $ensure = $php::params::ensure + $package = 'php5-pgsql' + $provider = undef + $inifile = "${php::params::config_root_ini}/pgsql.ini" + $pdo_inifile = "${php::params::config_root_ini}/pdo_pgsql.ini" + $settings = [ ] + $pdo_settings = [ ] } diff --git a/manifests/extension/sqlite.pp b/manifests/extension/sqlite.pp index 484b721a..2b0b2c6c 100644 --- a/manifests/extension/sqlite.pp +++ b/manifests/extension/sqlite.pp @@ -18,10 +18,17 @@ # [*inifile*] # The path to the extension ini file # +# [*pdo_inifile*] +# The path to the pdo extension ini file +# # [*settings*] # Hash with 'set' nested hash of key => value # set changes to agues when applied to *inifile* # +# [*pdo_settings*] +# Hash with 'set' nested hash of key => value +# set changes to agues when applied to *pdo_inifile* +# # === Variables # # No variables @@ -43,11 +50,13 @@ # Copyright 2012-2015 Christian "Jippi" Winther, unless otherwise noted. # class php::extension::sqlite( - $ensure = $php::extension::sqlite::params::ensure, - $package = $php::extension::sqlite::params::package, - $provider = $php::extension::sqlite::params::provider, - $inifile = $php::extension::sqlite::params::inifile, - $settings = $php::extension::sqlite::params::settings + $ensure = $php::extension::sqlite::params::ensure, + $package = $php::extension::sqlite::params::package, + $provider = $php::extension::sqlite::params::provider, + $inifile = $php::extension::sqlite::params::inifile, + $pdo_inifile = $php::extension::sqlite::params::pdo_inifile, + $settings = $php::extension::sqlite::params::settings, + $pdo_settings = $php::extension::sqlite::params::pdo_settings ) inherits php::extension::sqlite::params { php::extension { 'sqlite': @@ -60,4 +69,8 @@ file => $inifile, config => $settings } + php::config { 'php-extension-pdo_sqlite': + file => $pdo_inifile, + config => $pdo_settings + } } diff --git a/manifests/extension/sqlite/params.pp b/manifests/extension/sqlite/params.pp index eae4464e..1ca5dbfd 100644 --- a/manifests/extension/sqlite/params.pp +++ b/manifests/extension/sqlite/params.pp @@ -22,10 +22,17 @@ # [*inifile*] # The path to the extension ini file # +# [*pdo_inifile*] +# The path to the pdo extension ini file +# # [*settings*] # Hash with 'set' nested hash of key => value # set changes to agues when applied to *inifile* # +# [*pdo_settings*] +# Hash with 'set' nested hash of key => value +# set changes to agues when applied to *pod_inifile* +# # === Examples # # No examples @@ -40,9 +47,11 @@ # class php::extension::sqlite::params { - $ensure = $php::params::ensure - $package = 'php5-sqlite' - $provider = undef - $inifile = "${php::params::config_root_ini}/sqlite.ini" - $settings = [ ] + $ensure = $php::params::ensure + $package = 'php5-sqlite' + $provider = undef + $inifile = "${php::params::config_root_ini}/sqlite.ini" + $pdo_inifile = "${php::params::config_root_ini}/pdo_sqlite.ini" + $settings = [ ] + $pdo_settings = [ ] } diff --git a/spec/defines/config_spec.rb b/spec/defines/config_spec.rb index eb2fc5a7..e24b3341 100644 --- a/spec/defines/config_spec.rb +++ b/spec/defines/config_spec.rb @@ -29,7 +29,7 @@ }} it { should contain_php__config('unique-name').with({'file' => '/etc/php5/conf.d/unique-name.ini'})} - it { should contain_augeas("php-unique-name-config").with({'changes' => "set .anon/apc.enabled 1"})} + it { should contain_augeas("php-unique-name-config").with({'changes' => ["set .anon/apc.enabled 1"]})} end context 'invalid config (string)' do diff --git a/spec/defines/fpm_config_spec.rb b/spec/defines/fpm_config_spec.rb index ae3bb31c..82c77c1a 100644 --- a/spec/defines/fpm_config_spec.rb +++ b/spec/defines/fpm_config_spec.rb @@ -30,7 +30,7 @@ it { should contain_augeas("php-fpm-unique-name-config") .with({ 'incl' => '/etc/php5/fpm/conf.d/unique-name.ini', - 'changes' => "set .anon/apc.enabled 1" + 'changes' => [ "set .anon/apc.enabled 1" ], }) } diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp deleted file mode 100644 index e69de29b..00000000