From 97ae907c969e0d7897fd26e7abff0142e7ddbae5 Mon Sep 17 00:00:00 2001 From: sunnz Date: Sun, 21 Oct 2018 16:38:35 +1100 Subject: [PATCH 1/3] Added cli_settings parameter to ::php class. Allow specific settings for PHP CLI's php.ini file. --- manifests/init.pp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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': } From 856a12bd00af0245f76087274f81baf9401fde9b Mon Sep 17 00:00:00 2001 From: sunnz Date: Wed, 6 Mar 2019 09:22:30 +0000 Subject: [PATCH 2/3] Added unittest for cli_settings. --- spec/classes/php_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index e2538998..81f14e90 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' From 457591fa1b8faede0af228b4bb97479bf3e2db8f Mon Sep 17 00:00:00 2001 From: sunnz Date: Wed, 6 Mar 2019 09:51:13 +0000 Subject: [PATCH 3/3] Removed comma after the last item of a hash according to the Ruby style guide. Caught by RuboCop, Style/TrailingCommaInLiteral. See: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas --- spec/classes/php_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index 81f14e90..63c6408e 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -218,7 +218,7 @@ let(:params) do { 'settings' => { 'PHP/memory_limit' => '300M' }, - 'cli_settings' => { 'PHP/memory_limit' => '1000M' }, + 'cli_settings' => { 'PHP/memory_limit' => '1000M' } } end