Skip to content

Commit

Permalink
Merge pull request #2277 from ekohl/disable-mod-php-on-el9
Browse files Browse the repository at this point in the history
Disable mod_php on EL9
  • Loading branch information
david22swan authored Aug 8, 2022
2 parents c467cf4 + 51bc232 commit 2575f39
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 183 deletions.
7 changes: 6 additions & 1 deletion manifests/mod/php.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
# UNIX group of the root user
#
# @param php_version
# The php version
# The php version. This is a required parameter, but optional allows showing a clear error message
#
# @param libphp_prefix
#
# @note Unsupported platforms: RedHat: 9
class apache::mod::php (
Optional[String] $package_name = undef,
String $package_ensure = 'present',
Expand All @@ -37,6 +38,10 @@
Optional[String] $php_version = $apache::params::php_version,
String $libphp_prefix = 'libphp'
) inherits apache::params {
unless $php_version {
fail("${facts['os']['name']} ${facts['os']['release']['major']} does not support mod_php")
}

include apache
if (versioncmp($php_version, '8') < 0) {
$mod = "php${php_version}"
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
$passenger_ruby = undef
$passenger_default_ruby = undef
$php_version = $facts['os']['release']['major'] ? {
'9' => '8', # RedHat9
'9' => undef, # RedHat 9 doesn't ship mod_php
'8' => '7', # RedHat8
default => '5', # RedHat5, RedHat6, RedHat7
}
Expand Down
169 changes: 81 additions & 88 deletions spec/acceptance/mod_php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,94 @@
require 'spec_helper_acceptance'
apache_hash = apache_settings_hash

# Temporary exclusion pending resolution of https://github.com/puppetlabs/puppetlabs-apache/issues/2261
unless os[:family] == 'redhat' && os[:release].to_i == 9
describe 'apache::mod::php class', if: mod_supported_on_platform?('apache::mod::php') do
context 'default php config' do
pp = <<-MANIFEST
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
apache::vhost { 'php.example.com':
port => 80,
docroot => '#{apache_hash['doc_root']}/php',
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '#{apache_hash['doc_root']}/php/index.php':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
MANIFEST
it 'succeeds in puppeting php' do
apply_manifest(pp, catch_failures: true)
end
describe 'apache::mod::php class', if: mod_supported_on_platform?('apache::mod::php') do
context 'default php config' do
pp = <<-MANIFEST
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
apache::vhost { 'php.example.com':
port => 80,
docroot => '#{apache_hash['doc_root']}/php',
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '#{apache_hash['doc_root']}/php/index.php':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
MANIFEST
it 'succeeds in puppeting php' do
apply_manifest(pp, catch_failures: true)
end

if os[:family] == 'debian' && os[:release] =~ %r{^9\.}
describe file("#{apache_hash['mod_dir']}/php7.0.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'debian' && os[:release] =~ %r{^10\.}
describe file("#{apache_hash['mod_dir']}/php7.3.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'debian' && os[:release] =~ %r{^11\.}
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] == '18.04'
describe file("#{apache_hash['mod_dir']}/php7.2.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'ubuntu' && os[:release] == '20.04'
describe file("#{apache_hash['mod_dir']}/php7.4.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'redhat' && os[:release] =~ %r{^(9)\b}
describe file("#{apache_hash['mod_dir']}/php.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' }
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' }
end
if os[:family] == 'debian' && os[:release] =~ %r{^9\.}
describe file("#{apache_hash['mod_dir']}/php7.0.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'debian' && os[:release] =~ %r{^10\.}
describe file("#{apache_hash['mod_dir']}/php7.3.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'debian' && os[:release] =~ %r{^11\.}
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] == '18.04'
describe file("#{apache_hash['mod_dir']}/php7.2.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'ubuntu' && os[:release] == '20.04'
describe file("#{apache_hash['mod_dir']}/php7.4.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' }
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' }
end
end
end

context 'custom extensions, php_flag, php_value, php_admin_flag, and php_admin_value' do
pp = <<-MANIFEST
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php':
extensions => ['.php','.php5'],
context 'custom extensions, php_flag, php_value, php_admin_flag, and php_admin_value' do
pp = <<-MANIFEST
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php':
extensions => ['.php','.php5'],
}
apache::vhost { 'php.example.com':
port => 80,
docroot => '#{apache_hash['doc_root']}/php',
php_values => { 'include_path' => '.:/usr/share/pear:/usr/bin/php', },
php_flags => { 'display_errors' => 'on', },
php_admin_values => { 'open_basedir' => '/var/www/php/:/usr/share/pear/', },
php_admin_flags => { 'engine' => 'on', },
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '#{apache_hash['doc_root']}/php/index.php5':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
MANIFEST
it 'succeeds in puppeting php' do
apply_manifest(pp, catch_failures: true)
end
apache::vhost { 'php.example.com':
port => 80,
docroot => '#{apache_hash['doc_root']}/php',
php_values => { 'include_path' => '.:/usr/share/pear:/usr/bin/php', },
php_flags => { 'display_errors' => 'on', },
php_admin_values => { 'open_basedir' => '/var/www/php/:/usr/share/pear/', },
php_admin_flags => { 'engine' => 'on', },
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '#{apache_hash['doc_root']}/php/index.php5':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
MANIFEST
it 'succeeds in puppeting php' do
apply_manifest(pp, catch_failures: true)
end

describe file("#{apache_hash['vhost_dir']}/25-php.example.com.conf") do
it { is_expected.to contain ' php_flag display_errors on' }
it { is_expected.to contain ' php_value include_path ".:/usr/share/pear:/usr/bin/php"' }
it { is_expected.to contain ' php_admin_flag engine on' }
it { is_expected.to contain ' php_admin_value open_basedir /var/www/php/:/usr/share/pear/' }
end
describe file("#{apache_hash['vhost_dir']}/25-php.example.com.conf") do
it { is_expected.to contain ' php_flag display_errors on' }
it { is_expected.to contain ' php_value include_path ".:/usr/share/pear:/usr/bin/php"' }
it { is_expected.to contain ' php_admin_flag engine on' }
it { is_expected.to contain ' php_admin_value open_basedir /var/www/php/:/usr/share/pear/' }
end
end
end
Loading

0 comments on commit 2575f39

Please sign in to comment.