diff --git a/manifests/globals.pp b/manifests/globals.pp index 351b204..04ce1c6 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -1,159 +1,162 @@ # PHP globals class # # === Parameters # # [*php_version*] # The version of php. # # [*config_root*] # The configuration root directory. # # [*fpm_pid_file*] # Path to pid file for fpm # # [*rhscl_mode*] # The mode specifies the specifics in paths for the various RedHat SCL environments so that the module is configured # correctly on their pathnames. # # Valid modes are: 'rhscl', 'remi' # class php::globals ( Optional[Pattern[/^(rh-)?(php)?[57](\.)?[0-9]/]] $php_version = undef, Optional[Stdlib::Absolutepath] $config_root = undef, Optional[Stdlib::Absolutepath] $fpm_pid_file = undef, $rhscl_mode = undef, ) { $default_php_version = $facts['os']['name'] ? { 'Debian' => $facts['os']['release']['major'] ? { '9' => '7.0', - default => '7.3', + '10' => '7.3', + '11' => '7.4', + default => fail("Unsupported Debian release: ${fact('os.release.major')}"), }, 'Ubuntu' => $facts['os']['release']['major'] ? { - '20.04' => '7.4', '16.04' => '7.0', - default => '7.2', + '18.04' => '7.2', + '20.04' => '7.4', + default => fail("Unsupported Ubuntu release: ${fact('os.release.major')}"), }, default => '5.x', } $globals_php_version = pick($php_version, $default_php_version) case $facts['os']['family'] { 'Debian': { if $facts['os']['name'] == 'Ubuntu' { case $globals_php_version { /^[57].[0-9]/: { $default_config_root = "/etc/php/${globals_php_version}" $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid" $fpm_error_log = "/var/log/php${globals_php_version}-fpm.log" $fpm_service_name = "php${globals_php_version}-fpm" $ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}" $ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}" $package_prefix = "php${globals_php_version}-" } default: { # Default php installation from Ubuntu official repository use the following paths until 16.04 # For PPA please use the $php_version to override it. $default_config_root = '/etc/php5' $default_fpm_pid_file = '/var/run/php5-fpm.pid' $fpm_error_log = '/var/log/php5-fpm.log' $fpm_service_name = 'php5-fpm' $ext_tool_enable = '/usr/sbin/php5enmod' $ext_tool_query = '/usr/sbin/php5query' $package_prefix = 'php5-' } } } else { case $globals_php_version { /^5\.6/, /^7\.[0-9]/: { $default_config_root = "/etc/php/${globals_php_version}" $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid" $fpm_error_log = "/var/log/php${globals_php_version}-fpm.log" $fpm_service_name = "php${globals_php_version}-fpm" $ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}" $ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}" $package_prefix = "php${globals_php_version}-" } default: { $default_config_root = '/etc/php5' $default_fpm_pid_file = '/var/run/php5-fpm.pid' $fpm_error_log = '/var/log/php5-fpm.log' $fpm_service_name = 'php5-fpm' $ext_tool_enable = '/usr/sbin/php5enmod' $ext_tool_query = '/usr/sbin/php5query' $package_prefix = 'php5-' } } } } 'Suse': { case $globals_php_version { /^7/: { $default_config_root = '/etc/php7' $package_prefix = 'php7-' $default_fpm_pid_file = '/var/run/php7-fpm.pid' $fpm_error_log = '/var/log/php7-fpm.log' } default: { $default_config_root = '/etc/php5' $package_prefix = 'php5-' $default_fpm_pid_file = '/var/run/php5-fpm.pid' $fpm_error_log = '/var/log/php5-fpm.log' } } } 'RedHat': { case $rhscl_mode { 'remi': { $rhscl_root = "/opt/remi/${php_version}/root" $default_config_root = "/etc/opt/remi/${php_version}" $default_fpm_pid_file = '/var/run/php-fpm/php-fpm.pid' $package_prefix = "${php_version}-php-" $fpm_service_name = "${php_version}-php-fpm" } 'rhscl': { $rhscl_root = "/opt/rh/${php_version}/root" $default_config_root = "/etc/opt/rh/${php_version}" # rhscl registers contents by copy in /etc/opt/rh $default_fpm_pid_file = "/var/opt/rh/${php_version}/run/php-fpm/php-fpm.pid" $package_prefix = "${php_version}-php-" $fpm_service_name = "${php_version}-php-fpm" } undef: { $default_config_root = '/etc/php.d' $default_fpm_pid_file = '/var/run/php-fpm/php-fpm.pid' $fpm_service_name = undef $package_prefix = undef } default: { fail("Unsupported rhscl_mode '${rhscl_mode}'") } } } 'FreeBSD': { case $globals_php_version { /^(\d)\.(\d)$/: { $package_prefix = "php${1}${2}-" } default: { $package_prefix = 'php56-' } } $default_config_root = '/usr/local/etc' $default_fpm_pid_file = '/var/run/php-fpm.pid' $fpm_service_name = undef } 'Archlinux': { $default_config_root = '/etc/php' $default_fpm_pid_file = '/run/php-fpm/php-fpm.pid' } default: { fail("Unsupported osfamily: ${facts['os']['family']}") } } $globals_config_root = pick($config_root, $default_config_root) $globals_fpm_pid_file = pick($fpm_pid_file, $default_fpm_pid_file) } diff --git a/metadata.json b/metadata.json index 7e6ecdf..efa7eb9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,86 +1,87 @@ { "name": "puppet-php", "version": "7.1.1-rc0", "author": "Vox Pupuli", "summary": "Generic PHP module that supports many platforms", "license": "MIT", "source": "https://github.com/voxpupuli/puppet-php", "project_page": "https://github.com/voxpupuli/puppet-php", "issues_url": "https://github.com/voxpupuli/puppet-php/issues", "description": "Puppet module that aims to manage PHP and extensions in a generic way on many platforms with sane defaults and easy configuration", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.16.0 < 8.0.0" }, { "name": "puppetlabs/apt", "version_requirement": ">= 4.4.0 < 9.0.0" }, { "name": "puppetlabs/inifile", "version_requirement": ">= 1.4.1 < 6.0.0" }, { "name": "puppet/zypprepo", "version_requirement": ">= 2.0.0 < 3.0.0" }, { "name": "puppet/archive", "version_requirement": ">= 1.0.0 < 6.0.0" } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 6.1.0 < 8.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "16.04", "18.04", "20.04" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "9", - "10" + "10", + "11" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "7" ] }, { "operatingsystem": "FreeBSD", "operatingsystemrelease": [ "11" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ "11" ] }, { "operatingsystem": "OpenSUSE" }, { "operatingsystem": "Archlinux" } ] } diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 8b0bfd4..d3247f5 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -1,107 +1,111 @@ require 'spec_helper_acceptance' describe 'php with default settings' do context 'default parameters' do it 'works with defaults' do pp = 'include php' # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end case default[:platform] when %r{ubuntu-20.04} packagename = 'php7.4-fpm' when %r{ubuntu-18.04} packagename = 'php7.2-fpm' when %r{ubuntu-16.04} packagename = 'php7.0-fpm' when %r{el} packagename = 'php-fpm' when %r{debian-9} packagename = 'php7.0-fpm' when %r{debian-10} packagename = 'php7.3-fpm' + when %r{debian-11} + packagename = 'php7.4-fpm' end describe package(packagename) do it { is_expected.to be_installed } end describe service(packagename) do it { is_expected.to be_running } it { is_expected.to be_enabled } end end context 'default parameters with extensions' do case default[:platform] when %r{ubuntu-20.04}, %r{ubuntu-18.04}, %r{ubuntu-16.04} it 'works with defaults' do case default[:platform] when %r{ubuntu-20.04} simplexmlpackagename = 'php7.4-xml' when %r{ubuntu-18.04} simplexmlpackagename = 'php7.2-xml' when %r{ubuntu-16.04} simplexmlpackagename = 'php7.0-xml' end pp = <<-EOS class{'php': extensions => { 'mysql' => {}, 'gd' => {}, 'net-url' => { package_prefix => 'php-', settings => { extension => undef }, }, 'simplexml' => { package_name => '#{simplexmlpackagename}', } } } EOS # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end else it 'works with defaults' do pp = <<-EOS class{'php': extensions => { 'mysql' => {}, 'gd' => {} } } EOS # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end end case default[:platform] when %r{ubuntu-20.04} packagename = 'php7.4-fpm' when %r{ubuntu-18.04} packagename = 'php7.2-fpm' when %r{ubuntu-16.04} packagename = 'php7.0-fpm' when %r{el} packagename = 'php-fpm' when %r{debian-9} packagename = 'php7.0-fpm' when %r{debian-10} packagename = 'php7.3-fpm' + when %r{debian-11} + packagename = 'php7.4-fpm' end describe package(packagename) do it { is_expected.to be_installed } end describe service(packagename) do it { is_expected.to be_running } it { is_expected.to be_enabled } end end end