diff --git a/manifests/init.pp b/manifests/init.pp index 3bc6e3bd..df57a9bd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -111,6 +111,17 @@ # The package ensure of PHP pear to install and run pear auto_discover # # [*settings*] +# PHP configuration parameters in php.ini files as a hash. For example, +# 'Date/date.timezone' => 'Australia/Melbourne' sets data.timezone +# to 'Australia/Melbourne' under [Date] section, and +# 'PHP/memory_limit' => '256M' sets memory_limit to 256M. +# +# [*cli_settings*] +# Additional hash of PHP configuration parameters for PHP CLI. When a +# setting key already exists in $settings, the value provided from the +# $cli_settings parameter overrides the value from $settings parameter. +# For example, 'PHP/memory_limit' => '1000M' sets memory_limit to 1000M +# for the PHP cli ini file, regardless of the values from $settings. # class php ( String $ensure = $php::params::ensure, @@ -137,6 +148,7 @@ $proxy_server = undef, Hash $extensions = {}, Hash $settings = {}, + Hash $cli_settings = {}, $package_prefix = $php::params::package_prefix, Stdlib::Absolutepath $config_root_ini = $php::params::config_root_ini, Stdlib::Absolutepath $config_root_inifile = $php::params::config_root_inifile, @@ -154,6 +166,9 @@ $real_fpm_pools = $fpm_pools $real_fpm_global_pool_settings = $fpm_global_pool_settings + # Merge in additional or overridden settings for php::cli::settings. + $final_cli_settings = $real_settings + $cli_settings + if $manage_repos { class { 'php::repo': } -> Anchor['php::begin'] @@ -162,7 +177,7 @@ anchor { 'php::begin': } -> class { 'php::packages': } -> class { 'php::cli': - settings => $real_settings, + settings => $final_cli_settings, } -> anchor { 'php::end': } diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index e2538998..63c6408e 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -214,6 +214,19 @@ end if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'CentOS' + describe 'when called with cli_settings parameter' do + let(:params) do + { + 'settings' => { 'PHP/memory_limit' => '300M' }, + 'cli_settings' => { 'PHP/memory_limit' => '1000M' } + } + end + + it { is_expected.to contain_php__config__setting('/etc/php.ini: PHP/memory_limit').with_value('300M') } + it { is_expected.to contain_php__config__setting('/etc/php-fpm.ini: PHP/memory_limit').with_value('300M') } + it { is_expected.to contain_php__config__setting('/etc/php-cli.ini: PHP/memory_limit').with_value('1000M') } + end + describe 'when called with global option for rhscl_mode' do describe 'when called with mode "remi"' do scl_php_version = 'php56'