Skip to content

Commit

Permalink
Merge pull request #491 from sunnz/clisettings
Browse files Browse the repository at this point in the history
Add cli_settings parameter to php class
  • Loading branch information
bastelfreak authored Mar 6, 2019
2 parents 34ffabc + 457591f commit 64bbc0b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
17 changes: 16 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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']
Expand All @@ -162,7 +177,7 @@
anchor { 'php::begin': }
-> class { 'php::packages': }
-> class { 'php::cli':
settings => $real_settings,
settings => $final_cli_settings,
}
-> anchor { 'php::end': }

Expand Down
13 changes: 13 additions & 0 deletions spec/classes/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 64bbc0b

Please sign in to comment.