Skip to content

Commit f9710ef

Browse files
committed
Update for Ubuntu 22.04
1 parent 58078cc commit f9710ef

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

manifests/mod/php.pp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@
4343
}
4444

4545
include apache
46-
if (versioncmp($php_version, '8') < 0) {
47-
$mod = "php${php_version}"
48-
} else {
46+
# RedHat + PHP 8 drop the major version in apache module name.
47+
if ($facts['os']['family'] == 'RedHat') and (versioncmp($php_version, '8') >= 0) {
4948
$mod = 'php'
49+
} else {
50+
$mod = "php${php_version}"
5051
}
5152

5253
if $apache::version::scl_httpd_version == undef and $apache::version::scl_php_version != undef {
@@ -92,12 +93,11 @@
9293
$_php_version_no_dot = regsubst($php_version, '\.', '')
9394
if $apache::version::scl_httpd_version {
9495
$_lib = "librh-php${_php_version_no_dot}-php${_php_major}.so"
96+
} elsif ($facts['os']['family'] == 'RedHat') and ($_php_major == 8) {
97+
# RedHat + PHP 8 drop the major version in apache module name.
98+
$_lib = "${libphp_prefix}.so"
9599
} else {
96-
# Controls php version and libphp prefix
97-
$_lib = $_php_major ? {
98-
'8' => "${libphp_prefix}.so",
99-
default => "${libphp_prefix}${php_version}.so",
100-
}
100+
$_lib = "${libphp_prefix}${php_version}.so"
101101
}
102102
$_module_id = $_php_major ? {
103103
'5' => 'php5_module',

manifests/params.pp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,16 @@
345345
$default_ssl_cert = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
346346
$default_ssl_key = '/etc/ssl/private/ssl-cert-snakeoil.key'
347347
$ssl_sessioncache = "\${APACHE_RUN_DIR}/ssl_scache(512000)"
348-
if ($facts['os']['name'] == 'Ubuntu') or ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') < 0) {
349-
$php_version = $facts['os']['release']['major'] ? {
350-
'9' => '7.0', # Debian Stretch
351-
'10' => '7.3', # Debian Buster
352-
'20.04' => '7.4', # Ubuntu Foccal Fossal
353-
default => '7.2', # Ubuntu Bionic, Cosmic and Disco
354-
}
348+
$php_version = $facts['os']['release']['major'] ? {
349+
'9' => '7.0', # Debian Stretch
350+
'10' => '7.3', # Debian Buster
351+
'11' => '7.4', # Debian Bullseye
352+
'20.04' => '7.4', # Ubuntu Foccal Fossal
353+
'22.04' => '8.1', # Ubuntu Jammy
354+
default => '7.2', # Ubuntu Bionic, Cosmic and Disco
355+
}
356+
if (($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') < 0) or
357+
($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') < 0)) {
355358
$mod_packages = {
356359
'apreq2' => 'libapache2-mod-apreq2',
357360
'auth_cas' => 'libapache2-mod-auth-cas',
@@ -379,9 +382,6 @@
379382
'xsendfile' => 'libapache2-mod-xsendfile',
380383
}
381384
} else {
382-
$php_version = $facts['os']['release']['major'] ? {
383-
default => '7.4', # Debian Bullseye
384-
}
385385
$mod_packages = {
386386
'apreq2' => 'libapache2-mod-apreq2',
387387
'auth_cas' => 'libapache2-mod-auth-cas',

spec/acceptance/mod_php_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class { 'apache::mod::php': }
4444
describe file("#{apache_hash['mod_dir']}/php7.4.conf") do
4545
it { is_expected.to contain 'DirectoryIndex index.php' }
4646
end
47+
elsif os[:family] == 'ubuntu' && os[:release] == '22.04'
48+
describe file("#{apache_hash['mod_dir']}/php8.1.conf") do
49+
it { is_expected.to contain 'DirectoryIndex index.php' }
50+
end
4751
elsif os[:family] == 'redhat' && os[:release] =~ %r{^(8)\b}
4852
describe file("#{apache_hash['mod_dir']}/php7.conf") do
4953
it { is_expected.to contain 'DirectoryIndex index.php' }

spec/classes/mod/php_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
)
4141
}
4242

43-
context 'with experimental php8.0' do
43+
context 'with php8.0' do
4444
let :params do
4545
{ php_version: '8.0' }
4646
end
4747

48-
it { is_expected.to contain_apache__mod('php') }
48+
it { is_expected.to contain_apache__mod('php8.0') }
4949
it { is_expected.to contain_package('libapache2-mod-php8.0') }
5050
it {
51-
is_expected.to contain_file('php.load').with(
52-
content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n",
51+
is_expected.to contain_file('php8.0.load').with(
52+
content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n",
5353
)
5454
}
5555
end
@@ -64,16 +64,16 @@
6464
)
6565
}
6666

67-
context 'with experimental php8.0' do
67+
context 'with php8.0' do
6868
let :params do
6969
{ php_version: '8.0' }
7070
end
7171

72-
it { is_expected.to contain_apache__mod('php') }
72+
it { is_expected.to contain_apache__mod('php8.0') }
7373
it { is_expected.to contain_package('libapache2-mod-php8.0') }
7474
it {
75-
is_expected.to contain_file('php.load').with(
76-
content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n",
75+
is_expected.to contain_file('php8.0.load').with(
76+
content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n",
7777
)
7878
}
7979
end

0 commit comments

Comments
 (0)