From 6190306bfd7e1202a90f32c2514b9639d630183a Mon Sep 17 00:00:00 2001 From: Christian Castelli <34291598+cdamage@users.noreply.github.com> Date: Fri, 5 Feb 2021 15:23:14 -0600 Subject: [PATCH 1/5] Fix issues when using php8 PHP8 dropped the conventions of including the major versions in apache modules. This fix makes it so that moving forward the module will no longer add the major in the relevant places. before change: /etc/httpd/conf.modules.d/php8.conf /etc/httpd/conf.modules.d/php8.load ^---Content---^ LoadModule php8_module modules/libphp8.so Apache won't load After change: /etc/httpd/conf.modules.d/php.conf /etc/httpd/conf.modules.d/php.load ^---Content---^ LoadModule php_module modules/libphp.so --- manifests/mod/php.pp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index 7b320d0066..b8b1449d93 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -17,7 +17,11 @@ $libphp_prefix = 'libphp' ) inherits apache::params { include apache - $mod = "php${php_version}" + if $php_version <= '7' { + $mod = "php${php_version}" + } else { + $mod = "php" + } if $apache::version::scl_httpd_version == undef and $apache::version::scl_php_version != undef { fail('If you define apache::version::scl_php_version, you also need to specify apache::version::scl_httpd_version') @@ -75,7 +79,7 @@ id => "php${_php_major}_module", path => "${apache::lib_path}/mod_${mod}.so", } - } else { + } elsif $php_version <= '7' { ::apache::mod { $mod: package => $_package_name, package_ensure => $package_ensure, @@ -83,6 +87,14 @@ id => "php${_php_major}_module", path => $path, } + } else { + ::apache::mod { $mod: + package => $_package_name, + package_ensure => $package_ensure, + lib => "${libphp_prefix}.so", + id => "php_module", + path => $path, + } } include apache::mod::mime From 8dee6e17ad3d0751e374c541308414d6bdb03457 Mon Sep 17 00:00:00 2001 From: Ciaran McCrisken Date: Mon, 8 Feb 2021 10:14:33 +0000 Subject: [PATCH 2/5] (MODULES_10899) Use versioncmp function for $php_version Also remove restriction on tests so they execute on SLES platforms --- manifests/mod/php.pp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index b8b1449d93..25f857a456 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -3,7 +3,6 @@ # # @todo # Add docs -# @note Unsupported platforms: SLES: all class apache::mod::php ( $package_name = undef, $package_ensure = 'present', @@ -17,7 +16,7 @@ $libphp_prefix = 'libphp' ) inherits apache::params { include apache - if $php_version <= '7' { + if (versioncmp($php_version, '7') <= 0) { $mod = "php${php_version}" } else { $mod = "php" @@ -79,7 +78,7 @@ id => "php${_php_major}_module", path => "${apache::lib_path}/mod_${mod}.so", } - } elsif $php_version <= '7' { + } elsif (versioncmp($php_version, '7') <= 0) { ::apache::mod { $mod: package => $_package_name, package_ensure => $package_ensure, From 0d175da719a5809a91e7426119e98cd3f3ed98c7 Mon Sep 17 00:00:00 2001 From: Ciaran McCrisken Date: Mon, 8 Feb 2021 10:25:09 +0000 Subject: [PATCH 3/5] (MODULES-10899) Fix double quoted string issues --- manifests/mod/php.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index 25f857a456..0f15fba3f8 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -19,7 +19,7 @@ if (versioncmp($php_version, '7') <= 0) { $mod = "php${php_version}" } else { - $mod = "php" + $mod = 'php' } if $apache::version::scl_httpd_version == undef and $apache::version::scl_php_version != undef { @@ -91,7 +91,7 @@ package => $_package_name, package_ensure => $package_ensure, lib => "${libphp_prefix}.so", - id => "php_module", + id => 'php_module', path => $path, } } From 5285ae3ee31d2a539d9a451113f5a29ccd124bb1 Mon Sep 17 00:00:00 2001 From: Ciaran McCrisken Date: Mon, 8 Feb 2021 14:39:41 +0000 Subject: [PATCH 4/5] (MODULES-10899) Install PHP 7 by default on SLES >= 15 On SLES >= 15 it appears as though the `apache2-mod_php5` package is no longer available in the default repo. This commit ensures that the default value for the $php_version parameter is 7 on SLES >= 15 and the appropriate `apache2-mod_php7` package is used. The spec test expectations have also been updated based on the changes. --- manifests/mod/php.pp | 4 ++-- manifests/params.pp | 9 +++++---- spec/acceptance/mod_php_spec.rb | 4 ++++ spec/classes/mod/php_spec.rb | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index 0f15fba3f8..e072590c0a 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -16,7 +16,7 @@ $libphp_prefix = 'libphp' ) inherits apache::params { include apache - if (versioncmp($php_version, '7') <= 0) { + if (versioncmp($php_version, '8') < 0) { $mod = "php${php_version}" } else { $mod = 'php' @@ -78,7 +78,7 @@ id => "php${_php_major}_module", path => "${apache::lib_path}/mod_${mod}.so", } - } elsif (versioncmp($php_version, '7') <= 0) { + } elsif (versioncmp($php_version, '8') < 0) { ::apache::mod { $mod: package => $_package_name, package_ensure => $package_ensure, diff --git a/manifests/params.pp b/manifests/params.pp index bad6f3e5f7..0576ec0dc4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -698,26 +698,27 @@ $logroot_mode = undef $lib_path = '/usr/lib64/apache2' #changes for some modules based on mpm $mpm_module = 'prefork' - if versioncmp($::operatingsystemrelease, '15') < 0 { $default_ssl_cert = '/etc/apache2/ssl.crt/server.crt' $default_ssl_key = '/etc/apache2/ssl.key/server.key' + $php_version = '5' } else { $default_ssl_cert = '/etc/apache2/ssl.crt/default-server.crt' $default_ssl_key = '/etc/apache2/ssl.key/default-server.key' + $php_version = '7' } + $suphp_configpath = "/etc/php${php_version}/apache2" $ssl_sessioncache = '/var/lib/apache2/ssl_scache(512000)' $suphp_addhandler = 'x-httpd-php' $suphp_engine = 'off' - $suphp_configpath = '/etc/php5/apache2' - $php_version = '5' if versioncmp($::operatingsystemrelease, '11') < 0 or versioncmp($::operatingsystemrelease, '12') >= 0 { - $mod_packages = { + $mod_packages = { 'auth_kerb' => 'apache2-mod_auth_kerb', 'auth_gssapi' => 'apache2-mod_auth_gssapi', 'dav_svn' => 'subversion-server', 'perl' => 'apache2-mod_perl', 'php5' => 'apache2-mod_php5', + 'php7' => 'apache2-mod_php7', 'python' => 'apache2-mod_python', 'security' => 'apache2-mod_security2', 'worker' => 'apache2-worker', diff --git a/spec/acceptance/mod_php_spec.rb b/spec/acceptance/mod_php_spec.rb index b95f738542..2917445416 100644 --- a/spec/acceptance/mod_php_spec.rb +++ b/spec/acceptance/mod_php_spec.rb @@ -45,6 +45,10 @@ class { 'apache::mod::php': } describe file("#{apache_hash['mod_dir']}/php7.conf") do it { is_expected.to contain 'DirectoryIndex index.php' } end + elsif os[:family] == 'sles' && os[:release].to_i >= 15 + describe file("#{apache_hash['mod_dir']}/php7.conf") do + it { is_expected.to contain 'DirectoryIndex index.php' } + end else describe file("#{apache_hash['mod_dir']}/php5.conf") do it { is_expected.to contain 'DirectoryIndex index.php' } diff --git a/spec/classes/mod/php_spec.rb b/spec/classes/mod/php_spec.rb index 05a6de020f..1fb0637ba6 100644 --- a/spec/classes/mod/php_spec.rb +++ b/spec/classes/mod/php_spec.rb @@ -207,6 +207,7 @@ # all the following tests are for legacy php/apache versions. They don't work on modern ubuntu and redhat 8 next if (facts[:os]['release']['major'].to_i > 15 && facts[:os]['name'] == 'Ubuntu') || + (facts[:os]['release']['major'].to_i >= 15 && facts[:os]['name'] == 'SLES') || (facts[:os]['release']['major'].to_i >= 9 && facts[:os]['name'] == 'Debian') || (facts[:os]['release']['major'].to_i >= 8 && (facts[:os]['name'] == 'RedHat' || facts[:os]['name'] == 'CentOS')) From bc3f35caf02fd784f0754e9dff78b8a2950ec7cf Mon Sep 17 00:00:00 2001 From: Beat Christen Date: Mon, 15 Feb 2021 16:07:14 +0100 Subject: [PATCH 5/5] (MODULES-10899) Fix for debian10/experimental with tests This commit introduces the `$_module_id` variable which will be populated with the correct module ID based on the version specified. This makes things a bit more explicit and easier to follow. Also, two spec tests added for the following scenario: - Debian 10 (out of the box) using PHP 7.3 - Debian 10 (experimental) using PHP 8.0 --- manifests/mod/php.pp | 19 ++++++++----------- spec/classes/mod/php_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index e072590c0a..77cd0ed1f6 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -69,31 +69,28 @@ # Controls php version and libphp prefix $_lib = "${libphp_prefix}${php_version}.so" } + $_module_id = $_php_major ? { + '5' => 'php5_module', + '7' => 'php7_module', + default => 'php_module', + } if $::operatingsystem == 'SLES' { ::apache::mod { $mod: package => $_package_name, package_ensure => $package_ensure, lib => "mod_${mod}.so", - id => "php${_php_major}_module", + id => $_module_id, path => "${apache::lib_path}/mod_${mod}.so", } - } elsif (versioncmp($php_version, '8') < 0) { + } else { ::apache::mod { $mod: package => $_package_name, package_ensure => $package_ensure, lib => $_lib, - id => "php${_php_major}_module", + id => $_module_id, path => $path, } - } else { - ::apache::mod { $mod: - package => $_package_name, - package_ensure => $package_ensure, - lib => "${libphp_prefix}.so", - id => 'php_module', - path => $path, - } } include apache::mod::mime diff --git a/spec/classes/mod/php_spec.rb b/spec/classes/mod/php_spec.rb index 1fb0637ba6..885b1a2e6d 100644 --- a/spec/classes/mod/php_spec.rb +++ b/spec/classes/mod/php_spec.rb @@ -53,6 +53,29 @@ ) } end + when '10' + context 'on buster' do + it { is_expected.to contain_apache__mod('php7.3') } + it { is_expected.to contain_package('libapache2-mod-php7.3') } + it { + is_expected.to contain_file('php7.3.load').with( + content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.3.so\n", + ) + } + end + context 'on buster with experimental php8.0' do + let :params do + { php_version: '8.0' } + end + + it { is_expected.to contain_apache__mod('php') } + it { is_expected.to contain_package('libapache2-mod-php8.0') } + it { + is_expected.to contain_file('php.load').with( + content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n", + ) + } + end when '16.04' context 'on stretch' do let :params do