Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions manifests/mod/php.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#
# @todo
# Add docs
# @note Unsupported platforms: SLES: all
class apache::mod::php (
$package_name = undef,
$package_ensure = 'present',
Expand All @@ -17,7 +16,11 @@
$libphp_prefix = 'libphp'
) inherits apache::params {
include apache
$mod = "php${php_version}"
if (versioncmp($php_version, '8') < 0) {
$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')
Expand Down Expand Up @@ -66,21 +69,26 @@
# 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",
}
} else {
::apache::mod { $mod:
package => $_package_name,
package_ensure => $package_ensure,
lib => $_lib,
id => "php${_php_major}_module",
id => $_module_id,
path => $path,
}
}
Expand Down
9 changes: 5 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
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 @@ -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' }
Expand Down
24 changes: 24 additions & 0 deletions spec/classes/mod/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -207,6 +230,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'))

Expand Down