Skip to content

Commit 64bbc0b

Browse files
authored
Merge pull request #491 from sunnz/clisettings
Add cli_settings parameter to php class
2 parents 34ffabc + 457591f commit 64bbc0b

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

manifests/init.pp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@
111111
# The package ensure of PHP pear to install and run pear auto_discover
112112
#
113113
# [*settings*]
114+
# PHP configuration parameters in php.ini files as a hash. For example,
115+
# 'Date/date.timezone' => 'Australia/Melbourne' sets data.timezone
116+
# to 'Australia/Melbourne' under [Date] section, and
117+
# 'PHP/memory_limit' => '256M' sets memory_limit to 256M.
118+
#
119+
# [*cli_settings*]
120+
# Additional hash of PHP configuration parameters for PHP CLI. When a
121+
# setting key already exists in $settings, the value provided from the
122+
# $cli_settings parameter overrides the value from $settings parameter.
123+
# For example, 'PHP/memory_limit' => '1000M' sets memory_limit to 1000M
124+
# for the PHP cli ini file, regardless of the values from $settings.
114125
#
115126
class php (
116127
String $ensure = $php::params::ensure,
@@ -137,6 +148,7 @@
137148
$proxy_server = undef,
138149
Hash $extensions = {},
139150
Hash $settings = {},
151+
Hash $cli_settings = {},
140152
$package_prefix = $php::params::package_prefix,
141153
Stdlib::Absolutepath $config_root_ini = $php::params::config_root_ini,
142154
Stdlib::Absolutepath $config_root_inifile = $php::params::config_root_inifile,
@@ -154,6 +166,9 @@
154166
$real_fpm_pools = $fpm_pools
155167
$real_fpm_global_pool_settings = $fpm_global_pool_settings
156168

169+
# Merge in additional or overridden settings for php::cli::settings.
170+
$final_cli_settings = $real_settings + $cli_settings
171+
157172
if $manage_repos {
158173
class { 'php::repo': }
159174
-> Anchor['php::begin']
@@ -162,7 +177,7 @@
162177
anchor { 'php::begin': }
163178
-> class { 'php::packages': }
164179
-> class { 'php::cli':
165-
settings => $real_settings,
180+
settings => $final_cli_settings,
166181
}
167182
-> anchor { 'php::end': }
168183

spec/classes/php_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@
214214
end
215215

216216
if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'CentOS'
217+
describe 'when called with cli_settings parameter' do
218+
let(:params) do
219+
{
220+
'settings' => { 'PHP/memory_limit' => '300M' },
221+
'cli_settings' => { 'PHP/memory_limit' => '1000M' }
222+
}
223+
end
224+
225+
it { is_expected.to contain_php__config__setting('/etc/php.ini: PHP/memory_limit').with_value('300M') }
226+
it { is_expected.to contain_php__config__setting('/etc/php-fpm.ini: PHP/memory_limit').with_value('300M') }
227+
it { is_expected.to contain_php__config__setting('/etc/php-cli.ini: PHP/memory_limit').with_value('1000M') }
228+
end
229+
217230
describe 'when called with global option for rhscl_mode' do
218231
describe 'when called with mode "remi"' do
219232
scl_php_version = 'php56'

0 commit comments

Comments
 (0)