diff --git a/data/default.yaml b/data/default.yaml index 3451666..5e9d479 100644 --- a/data/default.yaml +++ b/data/default.yaml @@ -1,18 +1,6 @@ --- lookup_options: php::fpm::pools: merge: first -php::fpm::pools: - www: - catch_workers_output: 'no' - listen: '127.0.0.1:9000' - listen_backlog: '-1' - pm: dynamic - pm_max_children: 50 - pm_max_requests: 0 - pm_max_spare_servers: 35 - pm_min_spare_servers: 5 - pm_start_servers: 5 - request_terminate_timeout: 0 diff --git a/manifests/init.pp b/manifests/init.pp index c235baa..6318d77 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,246 +1,246 @@ # Base class with global configuration parameters that pulls in all # enabled components. # # === Parameters # # [*ensure*] # Specify which version of PHP packages to install, defaults to 'present'. # Please note that 'absent' to remove packages is not supported! # # [*manage_repos*] # Include repository (dotdeb, ppa, etc.) to install recent PHP from # # [*fpm*] # Install and configure php-fpm # # [*fpm_service_enable*] # Enable/disable FPM service # # [*fpm_service_ensure*] # Ensure FPM service is either 'running' or 'stopped' # # [*fpm_service_name*] # This is the name of the php-fpm service. It defaults to reasonable OS # defaults but can be different in case of using php7.0/other OS/custom fpm service # # [*fpm_service_provider*] # This is the name of the service provider, in case there is a non # OS default service provider used to start FPM. # Defaults to 'undef', pick system defaults. # # [*fpm_pools*] # Hash of php::fpm::pool resources that will be created. Defaults # to a single php::fpm::pool named www with default parameters. # # [*fpm_global_pool_settings*] # Hash of defaults params php::fpm::pool resources that will be created. # Defaults to empty hash. # # [*fpm_inifile*] # Path to php.ini for fpm # # [*fpm_package*] # Name of fpm package to install # # [*fpm_user*] # The user that php-fpm should run as # # [*fpm_group*] # The group that php-fpm should run as # # [*dev*] # Install php header files, needed to install pecl modules # # [*composer*] # Install and auto-update composer # # [*pear*] # Install PEAR # # [*phpunit*] # Install phpunit # # [*apache_config*] # Manage apache's mod_php configuration # # [*proxy_type*] # proxy server type (none|http|https|ftp) # # [*proxy_server*] # specify a proxy server, with port number if needed. ie: https://example.com:8080. # # [*extensions*] # Install PHP extensions, this is overwritten by hiera hash `php::extensions` # # [*package_prefix*] # This is the prefix for constructing names of php packages. This defaults # to a sensible default depending on your operating system, like 'php-' or # 'php5-'. # # [*config_root_ini*] # This is the path to the config .ini files of the extensions. This defaults # to a sensible default depending on your operating system, like # '/etc/php5/mods-available' or '/etc/php5/conf.d'. # # [*config_root_inifile*] # The path to the global php.ini file. This defaults to a sensible default # depending on your operating system. # # [*ext_tool_enable*] # Absolute path to php tool for enabling extensions in debian/ubuntu systems. # This defaults to '/usr/sbin/php5enmod'. # # [*ext_tool_query*] # Absolute path to php tool for querying information about extensions in # debian/ubuntu systems. This defaults to '/usr/sbin/php5query'. # # [*ext_tool_enabled*] # Enable or disable the use of php tools on debian based systems # debian/ubuntu systems. This defaults to 'true'. # # [*log_owner*] # The php-fpm log owner # # [*log_group*] # The group owning php-fpm logs # # [*embedded*] # Enable embedded SAPI # # [*pear_ensure*] # 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. # # [*pool_purge*] # Whether to purge pool config files not created # by this module # class php ( String $ensure = $php::params::ensure, Boolean $manage_repos = $php::params::manage_repos, Boolean $fpm = true, $fpm_service_enable = $php::params::fpm_service_enable, $fpm_service_ensure = $php::params::fpm_service_ensure, $fpm_service_name = $php::params::fpm_service_name, $fpm_service_provider = undef, - Hash $fpm_pools = {}, + Hash $fpm_pools = $php::params::fpm_pools, Hash $fpm_global_pool_settings = {}, $fpm_inifile = $php::params::fpm_inifile, $fpm_package = undef, $fpm_user = $php::params::fpm_user, $fpm_group = $php::params::fpm_group, Boolean $embedded = false, Boolean $dev = true, Boolean $composer = true, Boolean $pear = true, String $pear_ensure = $php::params::pear_ensure, Boolean $phpunit = false, Boolean $apache_config = false, $proxy_type = undef, $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, Optional[Stdlib::Absolutepath] $ext_tool_enable = $php::params::ext_tool_enable, Optional[Stdlib::Absolutepath] $ext_tool_query = $php::params::ext_tool_query, Boolean $ext_tool_enabled = $php::params::ext_tool_enabled, String $log_owner = $php::params::fpm_user, String $log_group = $php::params::fpm_group, Boolean $pool_purge = $php::params::pool_purge, ) inherits php::params { $real_fpm_package = pick($fpm_package, "${package_prefix}${php::params::fpm_package_suffix}") $real_settings = $settings $real_extensions = $extensions $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 { contain php::repo } class { 'php::packages': } -> class { 'php::cli': settings => $final_cli_settings, } contain php::packages contain php::cli # Configure global PHP settings in php.ini if $facts['os']['family'] != 'Debian' { Class['php::packages'] -> class {'php::global': settings => $real_settings, } contain php::global } if $fpm { contain 'php::fpm' } if $embedded { if $facts['os']['family'] == 'RedHat' and $fpm { # Both fpm and embeded SAPIs are using same php.ini fail('Enabling both cli and embedded sapis is not currently supported') } class { 'php::embedded': settings => $real_settings, } contain php::embedded } if $dev { contain php::dev } if $composer { class { 'php::composer': proxy_type => $proxy_type, proxy_server => $proxy_server, } } if $pear { class { 'php::pear': ensure => $pear_ensure, } } if $phpunit { contain php::phpunit } if $apache_config { class { 'php::apache_config': settings => $real_settings, } contain php::apache_config } create_resources('php::extension', $real_extensions, { require => Class['php::cli'], }) # On FreeBSD purge the system-wide extensions.ini. It is going # to be replaced with per-module configuration files. if $facts['os']['family'] == 'FreeBSD' { # Purge the system-wide extensions.ini file { '/usr/local/etc/php/extensions.ini': ensure => absent, require => Class['php::packages'], } } } diff --git a/manifests/params.pp b/manifests/params.pp index 6d0da0d..313e041 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,221 +1,236 @@ # PHP params class # class php::params inherits php::globals { $ensure = 'present' $fpm_service_enable = true $fpm_service_ensure = 'running' $composer_source = 'https://getcomposer.org/composer.phar' $composer_path = '/usr/local/bin/composer' $composer_max_age = 30 $pear_ensure = 'present' $pear_package_suffix = 'pear' $phpunit_source = 'https://phar.phpunit.de/phpunit.phar' $phpunit_path = '/usr/local/bin/phpunit' $phpunit_max_age = 30 $pool_purge = false + $fpm_pools = { + 'www' => { + 'catch_workers_output' => 'no', + 'listen' => '127.0.0.1:9000', + 'listen_backlog' => '-1', + 'pm' => 'dynamic', + 'pm_max_children' => 50, + 'pm_max_requests' => 0, + 'pm_max_spare_servers' => 35, + 'pm_min_spare_servers' => 5, + 'pm_start_servers' => 5, + 'request_terminate_timeout' => 0, + }, + } + case $facts['os']['family'] { 'Debian': { $config_root = $php::globals::globals_config_root $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" $dev_package_suffix = 'dev' $fpm_pid_file = $php::globals::globals_fpm_pid_file $fpm_config_file = "${config_root}/fpm/php-fpm.conf" $fpm_error_log = $php::globals::fpm_error_log $fpm_inifile = "${config_root}/fpm/php.ini" $fpm_package_suffix = 'fpm' $fpm_pool_dir = "${config_root}/fpm/pool.d" $fpm_service_name = $php::globals::fpm_service_name $fpm_user = 'www-data' $fpm_group = 'www-data' $apache_inifile = "${config_root}/apache2/php.ini" $embedded_package_suffix = 'embed' $embedded_inifile = "${config_root}/embed/php.ini" $package_prefix = $php::globals::package_prefix $compiler_packages = 'build-essential' $root_group = 'root' $ext_tool_enable = $php::globals::ext_tool_enable $ext_tool_query = $php::globals::ext_tool_query $ext_tool_enabled = true case $facts['os']['name'] { 'Debian': { $manage_repos = false } 'Ubuntu': { $manage_repos = false } default: { $manage_repos = false } } } 'Suse': { if ($php::globals::php_version != undef) { $php_version_major = regsubst($php::globals::php_version, '^(\d+)\.(\d+)$','\1') } else { $php_version_major = 5 } $config_root = $php::globals::globals_config_root $config_root_ini = "${config_root}/conf.d" $config_root_inifile = "${config_root}/php.ini" $common_package_names = ["php${php_version_major}"] $common_package_suffixes = [] $cli_inifile = "${config_root}/cli/php.ini" $dev_package_suffix = 'devel' $fpm_pid_file = $php::globals::globals_fpm_pid_file $fpm_config_file = "${config_root}/fpm/php-fpm.conf" $fpm_error_log = $php::globals::fpm_error_log $fpm_inifile = "${config_root}/fpm/php.ini" $fpm_package_suffix = 'fpm' $fpm_pool_dir = "${config_root}/fpm/pool.d" $fpm_service_name = 'php-fpm' $fpm_user = 'wwwrun' $fpm_group = 'www' $embedded_package_suffix = 'embed' $embedded_inifile = "${config_root}/embed/php.ini" $package_prefix = $php::globals::package_prefix $manage_repos = true $root_group = 'root' $ext_tool_enable = undef $ext_tool_query = undef $ext_tool_enabled = false case $facts['os']['name'] { 'SLES': { $compiler_packages = [] } 'OpenSuSE': { $compiler_packages = 'devel_basis' } default: { fail("Unsupported operating system ${facts['os']['name']}") } } } 'RedHat': { $config_root = $php::globals::globals_config_root case $php::globals::rhscl_mode { 'remi': { $config_root_ini = "${config_root}/php.d" $config_root_inifile = "${config_root}/php.ini" $cli_inifile = $config_root_inifile $fpm_inifile = $config_root_inifile $fpm_config_file = "${config_root}/php-fpm.conf" $fpm_pool_dir = "${config_root}/php-fpm.d" $php_bin_dir = "${php::globals::rhscl_root}/bin" } 'rhscl': { $config_root_ini = "${config_root}/php.d" $config_root_inifile = "${config_root}/php.ini" $cli_inifile = "${config_root}/php-cli.ini" $fpm_inifile = "${config_root}/php-fpm.ini" $fpm_config_file = "${config_root}/php-fpm.conf" $fpm_pool_dir = "${config_root}/php-fpm.d" $php_bin_dir = "${php::globals::rhscl_root}/bin" } undef: { # no rhscl $config_root_ini = $config_root $config_root_inifile = '/etc/php.ini' $cli_inifile = '/etc/php-cli.ini' $fpm_inifile = '/etc/php-fpm.ini' $fpm_config_file = '/etc/php-fpm.conf' $fpm_pool_dir = '/etc/php-fpm.d' } default: { fail("Unsupported rhscl_mode '${php::globals::rhscl_mode}'") } } $apache_inifile = $config_root_inifile $embedded_inifile = $config_root_inifile $common_package_names = [] $common_package_suffixes = ['cli', 'common'] $dev_package_suffix = 'devel' $fpm_pid_file = $php::globals::globals_fpm_pid_file $fpm_error_log = '/var/log/php-fpm/error.log' $fpm_package_suffix = 'fpm' $fpm_service_name = pick($php::globals::fpm_service_name, 'php-fpm') $fpm_user = 'apache' $fpm_group = 'apache' $embedded_package_suffix = 'embedded' $package_prefix = pick($php::globals::package_prefix, 'php-') $compiler_packages = ['gcc', 'gcc-c++', 'make'] $manage_repos = false $root_group = 'root' $ext_tool_enable = undef $ext_tool_query = undef $ext_tool_enabled = false } 'FreeBSD': { $config_root = $php::globals::globals_config_root $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. $common_package_names = [] $common_package_suffixes = ['extensions'] $cli_inifile = "${config_root}/php-cli.ini" $dev_package_suffix = undef $fpm_pid_file = $php::globals::globals_fpm_pid_file $fpm_config_file = "${config_root}/php-fpm.conf" $fpm_error_log = '/var/log/php-fpm.log' $fpm_inifile = "${config_root}/php-fpm.ini" $fpm_package_suffix = undef $fpm_pool_dir = "${config_root}/php-fpm.d" $fpm_service_name = 'php-fpm' $fpm_user = 'www' $fpm_group = 'www' $embedded_package_suffix = 'embed' $embedded_inifile = "${config_root}/php-embed.ini" $package_prefix = $php::globals::package_prefix $compiler_packages = ['gcc'] $manage_repos = false $root_group = 'wheel' $ext_tool_enable = undef $ext_tool_query = undef $ext_tool_enabled = false } 'Archlinux': { $config_root_ini = '/etc/php/conf.d' $config_root_inifile = '/etc/php/php.ini' $common_package_names = [] $common_package_suffixes = [] $cli_inifile = '/etc/php/php.ini' $dev_package_suffix = undef $fpm_pid_file = '/run/php-fpm/php-fpm.pid' $fpm_config_file = '/etc/php/php-fpm.conf' $fpm_error_log = 'syslog' $fpm_inifile = '/etc/php/php.ini' $fpm_package_suffix = 'fpm' $fpm_pool_dir = '/etc/php/php-fpm.d' $fpm_service_name = 'php-fpm' $fpm_user = 'root' $fpm_group = 'root' $apache_inifile = '/etc/php/php.ini' $embedded_package_suffix = 'embedded' $embedded_inifile = '/etc/php/php.ini' $package_prefix = 'php-' $compiler_packages = ['gcc', 'make'] $manage_repos = false $root_group = 'root' $ext_tool_enable = undef $ext_tool_query = undef $ext_tool_enabled = false } default: { fail("Unsupported osfamily: ${facts['os']['family']}") } } } diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index 9efc002..ebb765d 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -1,314 +1,321 @@ require 'spec_helper' describe 'php', type: :class do on_supported_os.each do |os, facts| context "on #{os}" do let :facts do facts end php_cli_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' 'php7.3-cli' when '9' 'php7.0-cli' else 'php5-cli' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' 'php7.2-cli' when '16.04' 'php7.0-cli' else 'php5-cli' end end php_fpm_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' 'php7.3-fpm' when '9' 'php7.0-fpm' else 'php5-fpm' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' 'php7.2-fpm' when '16.04' 'php7.0-fpm' else 'php5-fpm' end end php_dev_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' 'php7.3-dev' when '9' 'php7.0-dev' else 'php5-dev' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' 'php7.2-dev' when '16.04' 'php7.0-dev' else 'php5-dev' end end describe 'when called with no parameters' do case facts[:osfamily] when 'Suse', 'RedHat', 'CentOS' it { is_expected.to contain_class('php::global') } end case facts[:osfamily] when 'Debian' it { is_expected.not_to contain_class('php::global') } it { is_expected.to contain_class('php::fpm') } it { is_expected.to contain_package('php-pear').with_ensure('present') } it { is_expected.to contain_class('php::composer') } it { is_expected.to contain_package(php_cli_package).with_ensure('present') } it { is_expected.to contain_package(php_fpm_package).with_ensure('present') } it { is_expected.to contain_package(php_dev_package).with_ensure('present') } when 'Suse' it { is_expected.to contain_package('php5').with_ensure('present') } it { is_expected.to contain_package('php5-devel').with_ensure('present') } it { is_expected.to contain_package('php5-pear').with_ensure('present') } it { is_expected.not_to contain_package('php5-cli') } it { is_expected.not_to contain_package('php5-dev') } it { is_expected.not_to contain_package('php-pear') } when 'RedHat', 'CentOS' it { is_expected.to contain_package('php-cli').with_ensure('present') } it { is_expected.to contain_package('php-common').with_ensure('present') } end end describe 'when called with extensions' do let(:params) { { extensions: { xml: {} } } } it { is_expected.to contain_php__extension('xml').with_ensure('present') } end describe 'when called with ensure absent and extensions' do extensions = { xml: {} } let(:params) { { ensure: 'absent', extensions: extensions } } it { is_expected.to contain_php__extension('xml').with_ensure('absent') } case facts[:osfamily] when 'Debian' it { is_expected.to contain_package(php_cli_package).with_ensure('absent') } it { is_expected.to contain_package(php_fpm_package).with_ensure('absent') } it { is_expected.to contain_package(php_dev_package).with_ensure('absent') } when 'Suse' it { is_expected.to contain_package('php5').with_ensure('absent') } it { is_expected.to contain_package('php5-devel').with_ensure('absent') } when 'RedHat', 'CentOS' it { is_expected.to contain_package('php-cli').with_ensure('absent') } it { is_expected.to contain_package('php-common').with_ensure('absent') } end end describe 'when called with package_prefix parameter' do package_prefix = 'myphp-' let(:params) { { package_prefix: package_prefix } } case facts[:osfamily] when 'Suse', 'RedHat', 'CentOS' it { is_expected.to contain_class('php::global') } end case facts[:osfamily] when 'Debian', 'RedHat', 'CentOS' it { is_expected.to contain_package("#{package_prefix}cli").with_ensure('present') } end case facts[:osfamily] when 'Debian' it { is_expected.not_to contain_class('php::global') } it { is_expected.to contain_class('php::fpm') } it { is_expected.to contain_class('php::composer') } it { is_expected.to contain_package('php-pear').with_ensure('present') } it { is_expected.to contain_package("#{package_prefix}dev").with_ensure('present') } it { is_expected.to contain_package("#{package_prefix}fpm").with_ensure('present') } when 'Suse' it { is_expected.to contain_package('php5').with_ensure('present') } it { is_expected.to contain_package("#{package_prefix}devel").with_ensure('present') } it { is_expected.to contain_package("#{package_prefix}pear").with_ensure('present') } it { is_expected.not_to contain_package("#{package_prefix}cli").with_ensure('present') } it { is_expected.not_to contain_package("#{package_prefix}dev") } it { is_expected.not_to contain_package('php-pear') } when 'RedHat', 'CentOS' it { is_expected.to contain_package("#{package_prefix}common").with_ensure('present') } end end describe 'when called with fpm_user parameter' do let(:params) { { fpm_user: 'nginx' } } it { is_expected.to contain_class('php::fpm').with(user: 'nginx') } it { is_expected.to contain_php__fpm__pool('www').with(user: 'nginx') } dstfile = case facts[:osfamily] when 'Debian' case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' '/etc/php/7.3/fpm/pool.d/www.conf' when '9' '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' '/etc/php/7.2/fpm/pool.d/www.conf' when '16.04' '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end end when 'Archlinux' '/etc/php/php-fpm.d/www.conf' when 'Suse' '/etc/php5/fpm/pool.d/www.conf' when 'RedHat' '/etc/php-fpm.d/www.conf' when 'FreeBSD' '/usr/local/etc/php-fpm.d/www.conf' end it { is_expected.to contain_file(dstfile).with_content(%r{user = nginx}) } end describe 'when called with fpm_group parameter' do let(:params) { { fpm_group: 'nginx' } } it { is_expected.to contain_class('php::fpm').with(group: 'nginx') } it { is_expected.to contain_php__fpm__pool('www').with(group: 'nginx') } dstfile = case facts[:osfamily] when 'Debian' case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' '/etc/php/7.3/fpm/pool.d/www.conf' when '9' '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' '/etc/php/7.2/fpm/pool.d/www.conf' when '16.04' '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end end when 'Archlinux' '/etc/php/php-fpm.d/www.conf' when 'Suse' '/etc/php5/fpm/pool.d/www.conf' when 'RedHat' '/etc/php-fpm.d/www.conf' when 'FreeBSD' '/usr/local/etc/php-fpm.d/www.conf' end it { is_expected.to contain_file(dstfile).with_content(%r{group = nginx}) } end describe 'when fpm is disabled' do let(:params) { { fpm: false } } it { is_expected.not_to contain_class('php::fpm') } end describe 'when composer is disabled' do let(:params) { { composer: false } } it { is_expected.not_to contain_class('php::composer') } 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' rhscl_mode = 'remi' let(:pre_condition) do "class {'::php::globals': php_version => '#{scl_php_version}', rhscl_mode => '#{rhscl_mode}' }" end let(:params) do { settings: { 'Date/date.timezone' => 'Europe/Berlin' } } end it { is_expected.to contain_class('php::global') } it { is_expected.to contain_package("#{scl_php_version}-php-cli").with_ensure('present') } it { is_expected.to contain_package("#{scl_php_version}-php-common").with_ensure('present') } it { is_expected.to contain_php__config('global').with(file: "/etc/opt/#{rhscl_mode}/#{scl_php_version}/php.ini") } it { is_expected.not_to contain_php__config('cli') } # see: https://github.com/voxpupuli/puppet-php/blob/master/lib/puppet/parser/functions/to_hash_settings.rb it { is_expected.to contain_php__config__setting("/etc/opt/#{rhscl_mode}/#{scl_php_version}/php.ini: Date/date.timezone").with_value('Europe/Berlin') } end describe 'when called with mode "rhscl"' do scl_php_version = 'rh-php56' rhscl_mode = 'rhscl' let(:pre_condition) do "class {'::php::globals': php_version => '#{scl_php_version}', rhscl_mode => '#{rhscl_mode}' }" end let(:params) do { settings: { 'Date/date.timezone' => 'Europe/Berlin' } } end it { is_expected.to contain_class('php::global') } it { is_expected.to contain_package("#{scl_php_version}-php-cli").with_ensure('present') } it { is_expected.to contain_package("#{scl_php_version}-php-common").with_ensure('present') } it { is_expected.to contain_php__config('global').with(file: "/etc/opt/rh/#{scl_php_version}/php.ini") } it { is_expected.to contain_php__config('cli').with(file: "/etc/opt/rh/#{scl_php_version}/php-cli.ini") } it { is_expected.to contain_php__config__setting("/etc/opt/rh/#{scl_php_version}/php.ini: Date/date.timezone").with_value('Europe/Berlin') } end end end + + describe 'when called with pool_purge => true and fpm_pools => {}' do + let(:params) { { pool_purge: true, fpm_pools: {} } } + + it { is_expected.to contain_class('php::fpm').with(pool_purge: true) } + it { is_expected.not_to contain_php__fpm__pool('www') } + end end end end