Skip to content

Commit

Permalink
Update for Ubuntu 22.04
Browse files Browse the repository at this point in the history
  • Loading branch information
david22swan committed Aug 17, 2022
1 parent 58078cc commit f9710ef
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
16 changes: 8 additions & 8 deletions manifests/mod/php.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@
}

include apache
if (versioncmp($php_version, '8') < 0) {
$mod = "php${php_version}"
} else {
# RedHat + PHP 8 drop the major version in apache module name.
if ($facts['os']['family'] == 'RedHat') and (versioncmp($php_version, '8') >= 0) {
$mod = 'php'
} else {
$mod = "php${php_version}"
}

if $apache::version::scl_httpd_version == undef and $apache::version::scl_php_version != undef {
Expand Down Expand Up @@ -92,12 +93,11 @@
$_php_version_no_dot = regsubst($php_version, '\.', '')
if $apache::version::scl_httpd_version {
$_lib = "librh-php${_php_version_no_dot}-php${_php_major}.so"
} elsif ($facts['os']['family'] == 'RedHat') and ($_php_major == 8) {
# RedHat + PHP 8 drop the major version in apache module name.
$_lib = "${libphp_prefix}.so"
} else {
# Controls php version and libphp prefix
$_lib = $_php_major ? {
'8' => "${libphp_prefix}.so",
default => "${libphp_prefix}${php_version}.so",
}
$_lib = "${libphp_prefix}${php_version}.so"
}
$_module_id = $_php_major ? {
'5' => 'php5_module',
Expand Down
20 changes: 10 additions & 10 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,16 @@
$default_ssl_cert = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
$default_ssl_key = '/etc/ssl/private/ssl-cert-snakeoil.key'
$ssl_sessioncache = "\${APACHE_RUN_DIR}/ssl_scache(512000)"
if ($facts['os']['name'] == 'Ubuntu') or ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') < 0) {
$php_version = $facts['os']['release']['major'] ? {
'9' => '7.0', # Debian Stretch
'10' => '7.3', # Debian Buster
'20.04' => '7.4', # Ubuntu Foccal Fossal
default => '7.2', # Ubuntu Bionic, Cosmic and Disco
}
$php_version = $facts['os']['release']['major'] ? {
'9' => '7.0', # Debian Stretch
'10' => '7.3', # Debian Buster
'11' => '7.4', # Debian Bullseye
'20.04' => '7.4', # Ubuntu Foccal Fossal
'22.04' => '8.1', # Ubuntu Jammy
default => '7.2', # Ubuntu Bionic, Cosmic and Disco
}
if (($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') < 0) or
($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') < 0)) {
$mod_packages = {
'apreq2' => 'libapache2-mod-apreq2',
'auth_cas' => 'libapache2-mod-auth-cas',
Expand Down Expand Up @@ -379,9 +382,6 @@
'xsendfile' => 'libapache2-mod-xsendfile',
}
} else {
$php_version = $facts['os']['release']['major'] ? {
default => '7.4', # Debian Bullseye
}
$mod_packages = {
'apreq2' => 'libapache2-mod-apreq2',
'auth_cas' => 'libapache2-mod-auth-cas',
Expand Down
4 changes: 4 additions & 0 deletions spec/acceptance/mod_php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class { 'apache::mod::php': }
describe file("#{apache_hash['mod_dir']}/php7.4.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'ubuntu' && os[:release] == '22.04'
describe file("#{apache_hash['mod_dir']}/php8.1.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'redhat' && os[:release] =~ %r{^(8)\b}
describe file("#{apache_hash['mod_dir']}/php7.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
Expand Down
16 changes: 8 additions & 8 deletions spec/classes/mod/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
)
}

context 'with experimental php8.0' do
context 'with php8.0' do
let :params do
{ php_version: '8.0' }
end

it { is_expected.to contain_apache__mod('php') }
it { is_expected.to contain_apache__mod('php8.0') }
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/libphp.so\n",
is_expected.to contain_file('php8.0.load').with(
content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n",
)
}
end
Expand All @@ -64,16 +64,16 @@
)
}

context 'with experimental php8.0' do
context 'with php8.0' do
let :params do
{ php_version: '8.0' }
end

it { is_expected.to contain_apache__mod('php') }
it { is_expected.to contain_apache__mod('php8.0') }
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/libphp.so\n",
is_expected.to contain_file('php8.0.load').with(
content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n",
)
}
end
Expand Down

0 comments on commit f9710ef

Please sign in to comment.