From 54f37100f5ba1c1347ce9b203685cc30762f03be Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Tue, 17 Nov 2015 16:40:52 -0500 Subject: [PATCH] feat(global) Add php.ini global settings Fixes #132. --- manifests/global.pp | 33 +++++++++++++++++++++++++++++++++ manifests/init.pp | 7 +++++++ manifests/params.pp | 8 ++++++-- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 manifests/global.pp diff --git a/manifests/global.pp b/manifests/global.pp new file mode 100644 index 00000000..f172aa79 --- /dev/null +++ b/manifests/global.pp @@ -0,0 +1,33 @@ +# Install and configure mod_php for fpm +# +# === Parameters +# +# [*inifile*] +# Absolute path to the global php.ini file. Defaults +# to the OS specific default location as defined in params. +# [*settings*] +# Hash of settings to apply to the global php.ini file. +# Defaults to OS specific defaults (i.e. add nothing) +# + +# +class php::global( + $inifile = $::php::params::config_root_inifile, + $settings = {} +) inherits ::php::params { + + if $caller_module_name != $module_name { + warning('php::global is private') + } + + validate_absolute_path($inifile) + validate_hash($settings) + + # No deep merging required since the settings we have are the global settings. + $real_settings = $settings + + ::php::config { 'global': + file => $inifile, + config => $real_settings, + } +} diff --git a/manifests/init.pp b/manifests/init.pp index 8eff5118..4aa34395 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -128,6 +128,13 @@ } -> anchor { 'php::end': } + # Configure global PHP settings in php.ini + Anchor['php::begin'] -> + class {'::php::global': + settings => $real_settings, + } -> + Anchor['php::end'] + if $fpm { Anchor['php::begin'] -> class { '::php::fpm': diff --git a/manifests/params.pp b/manifests/params.pp index 6dc60128..f26ffbc3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -24,6 +24,7 @@ 'Debian': { $config_root = pick($cfg_root, '/etc/php5') $config_root_ini = "${config_root}/mods-available" + $config_root_inifile = "${config_root}/php.ini" $common_package_names = [] $common_package_suffixes = ['cli', 'common'] $cli_inifile = "${config_root}/cli/php.ini" @@ -63,6 +64,7 @@ 'Suse': { $config_root = pick($cfg_root, '/etc/php5') $config_root_ini = "${config_root}/conf.d" + $config_root_inifile = "${config_root}/php.ini" $common_package_names = ['php5'] $common_package_suffixes = [] $cli_inifile = "${config_root}/cli/php.ini" @@ -95,6 +97,7 @@ } 'RedHat': { $config_root_ini = '/etc/php.d' + $config_root_inifile = '/etc/php.ini' $common_package_names = [] $common_package_suffixes = ['cli', 'common'] $cli_inifile = '/etc/php-cli.ini' @@ -102,7 +105,7 @@ $fpm_pid_file = '/var/run/php-fpm/php-fpm.pid' $fpm_config_file = '/etc/php-fpm.conf' $fpm_error_log = '/var/log/php-fpm/error.log' - $fpm_inifile = '/etc/php.ini' + $fpm_inifile = '/etc/php-fpm.ini' $fpm_package_suffix = 'fpm' $fpm_pool_dir = '/etc/php-fpm.d' $fpm_service_name = 'php-fpm' @@ -118,6 +121,7 @@ 'FreeBSD': { $config_root = pick($cfg_root, '/usr/local/etc') $config_root_ini = "${config_root}/php" + $config_root_inifile = "${config_root}/php.ini" # No common packages, because the required PHP base package will be # pulled in as a dependency. This preserves the ability to choose # any available PHP version by setting the 'package_prefix' parameter. @@ -128,7 +132,7 @@ $fpm_pid_file = '/var/run/php-fpm.pid' $fpm_config_file = "${config_root}/php-fpm.conf" $fpm_error_log = '/var/log/php-fpm.log' - $fpm_inifile = "${config_root}/php.ini" + $fpm_inifile = "${config_root}/php-fpm.ini" $fpm_package_suffix = undef $fpm_pool_dir = "${config_root}/php-fpm.d" $fpm_service_name = 'php-fpm'