Skip to content

Commit 4bb4078

Browse files
authored
Merge pull request #2121 from sanfrancrisko/MODULES-10899/main/apache_php8_mod_name
(MODULES-10899) Handle PHP8 MOD package naming convention changes
2 parents b54431d + bc3f35c commit 4bb4078

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

manifests/mod/php.pp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#
44
# @todo
55
# Add docs
6-
# @note Unsupported platforms: SLES: all
76
class apache::mod::php (
87
$package_name = undef,
98
$package_ensure = 'present',
@@ -17,7 +16,11 @@
1716
$libphp_prefix = 'libphp'
1817
) inherits apache::params {
1918
include apache
20-
$mod = "php${php_version}"
19+
if (versioncmp($php_version, '8') < 0) {
20+
$mod = "php${php_version}"
21+
} else {
22+
$mod = 'php'
23+
}
2124

2225
if $apache::version::scl_httpd_version == undef and $apache::version::scl_php_version != undef {
2326
fail('If you define apache::version::scl_php_version, you also need to specify apache::version::scl_httpd_version')
@@ -66,21 +69,26 @@
6669
# Controls php version and libphp prefix
6770
$_lib = "${libphp_prefix}${php_version}.so"
6871
}
72+
$_module_id = $_php_major ? {
73+
'5' => 'php5_module',
74+
'7' => 'php7_module',
75+
default => 'php_module',
76+
}
6977

7078
if $::operatingsystem == 'SLES' {
7179
::apache::mod { $mod:
7280
package => $_package_name,
7381
package_ensure => $package_ensure,
7482
lib => "mod_${mod}.so",
75-
id => "php${_php_major}_module",
83+
id => $_module_id,
7684
path => "${apache::lib_path}/mod_${mod}.so",
7785
}
7886
} else {
7987
::apache::mod { $mod:
8088
package => $_package_name,
8189
package_ensure => $package_ensure,
8290
lib => $_lib,
83-
id => "php${_php_major}_module",
91+
id => $_module_id,
8492
path => $path,
8593
}
8694
}

manifests/params.pp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,26 +698,27 @@
698698
$logroot_mode = undef
699699
$lib_path = '/usr/lib64/apache2' #changes for some modules based on mpm
700700
$mpm_module = 'prefork'
701-
702701
if versioncmp($::operatingsystemrelease, '15') < 0 {
703702
$default_ssl_cert = '/etc/apache2/ssl.crt/server.crt'
704703
$default_ssl_key = '/etc/apache2/ssl.key/server.key'
704+
$php_version = '5'
705705
} else {
706706
$default_ssl_cert = '/etc/apache2/ssl.crt/default-server.crt'
707707
$default_ssl_key = '/etc/apache2/ssl.key/default-server.key'
708+
$php_version = '7'
708709
}
710+
$suphp_configpath = "/etc/php${php_version}/apache2"
709711
$ssl_sessioncache = '/var/lib/apache2/ssl_scache(512000)'
710712
$suphp_addhandler = 'x-httpd-php'
711713
$suphp_engine = 'off'
712-
$suphp_configpath = '/etc/php5/apache2'
713-
$php_version = '5'
714714
if versioncmp($::operatingsystemrelease, '11') < 0 or versioncmp($::operatingsystemrelease, '12') >= 0 {
715-
$mod_packages = {
715+
$mod_packages = {
716716
'auth_kerb' => 'apache2-mod_auth_kerb',
717717
'auth_gssapi' => 'apache2-mod_auth_gssapi',
718718
'dav_svn' => 'subversion-server',
719719
'perl' => 'apache2-mod_perl',
720720
'php5' => 'apache2-mod_php5',
721+
'php7' => 'apache2-mod_php7',
721722
'python' => 'apache2-mod_python',
722723
'security' => 'apache2-mod_security2',
723724
'worker' => 'apache2-worker',

spec/acceptance/mod_php_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class { 'apache::mod::php': }
4545
describe file("#{apache_hash['mod_dir']}/php7.conf") do
4646
it { is_expected.to contain 'DirectoryIndex index.php' }
4747
end
48+
elsif os[:family] == 'sles' && os[:release].to_i >= 15
49+
describe file("#{apache_hash['mod_dir']}/php7.conf") do
50+
it { is_expected.to contain 'DirectoryIndex index.php' }
51+
end
4852
else
4953
describe file("#{apache_hash['mod_dir']}/php5.conf") do
5054
it { is_expected.to contain 'DirectoryIndex index.php' }

spec/classes/mod/php_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@
5353
)
5454
}
5555
end
56+
when '10'
57+
context 'on buster' do
58+
it { is_expected.to contain_apache__mod('php7.3') }
59+
it { is_expected.to contain_package('libapache2-mod-php7.3') }
60+
it {
61+
is_expected.to contain_file('php7.3.load').with(
62+
content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.3.so\n",
63+
)
64+
}
65+
end
66+
context 'on buster with experimental php8.0' do
67+
let :params do
68+
{ php_version: '8.0' }
69+
end
70+
71+
it { is_expected.to contain_apache__mod('php') }
72+
it { is_expected.to contain_package('libapache2-mod-php8.0') }
73+
it {
74+
is_expected.to contain_file('php.load').with(
75+
content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n",
76+
)
77+
}
78+
end
5679
when '16.04'
5780
context 'on stretch' do
5881
let :params do
@@ -207,6 +230,7 @@
207230

208231
# all the following tests are for legacy php/apache versions. They don't work on modern ubuntu and redhat 8
209232
next if (facts[:os]['release']['major'].to_i > 15 && facts[:os]['name'] == 'Ubuntu') ||
233+
(facts[:os]['release']['major'].to_i >= 15 && facts[:os]['name'] == 'SLES') ||
210234
(facts[:os]['release']['major'].to_i >= 9 && facts[:os]['name'] == 'Debian') ||
211235
(facts[:os]['release']['major'].to_i >= 8 && (facts[:os]['name'] == 'RedHat' || facts[:os]['name'] == 'CentOS'))
212236

0 commit comments

Comments
 (0)