Skip to content

Commit 51bc232

Browse files
committed
Declare mod_php unsupported on EL9
EL 9 doesn't ship mod_php, so this is uninstallable. By making it a required parameter (which effectively was already the case) and setting the version to undef the catalog fails to compile by default. This still allows users to set it if they build a mod_php somehow. EL 9 users should use php-fpm instead. Fixes: edbdb65
1 parent 1d436fd commit 51bc232

File tree

4 files changed

+186
-183
lines changed

4 files changed

+186
-183
lines changed

manifests/mod/php.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
# UNIX group of the root user
2222
#
2323
# @param php_version
24-
# The php version
24+
# The php version. This is a required parameter, but optional allows showing a clear error message
2525
#
2626
# @param libphp_prefix
2727
#
28+
# @note Unsupported platforms: RedHat: 9
2829
class apache::mod::php (
2930
Optional[String] $package_name = undef,
3031
String $package_ensure = 'present',
@@ -37,6 +38,10 @@
3738
Optional[String] $php_version = $apache::params::php_version,
3839
String $libphp_prefix = 'libphp'
3940
) inherits apache::params {
41+
unless $php_version {
42+
fail("${facts['os']['name']} ${facts['os']['release']['major']} does not support mod_php")
43+
}
44+
4045
include apache
4146
if (versioncmp($php_version, '8') < 0) {
4247
$mod = "php${php_version}"

manifests/params.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
$passenger_ruby = undef
198198
$passenger_default_ruby = undef
199199
$php_version = $facts['os']['release']['major'] ? {
200-
'9' => '8', # RedHat9
200+
'9' => undef, # RedHat 9 doesn't ship mod_php
201201
'8' => '7', # RedHat8
202202
default => '5', # RedHat5, RedHat6, RedHat7
203203
}

spec/acceptance/mod_php_spec.rb

Lines changed: 81 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -3,101 +3,94 @@
33
require 'spec_helper_acceptance'
44
apache_hash = apache_settings_hash
55

6-
# Temporary exclusion pending resolution of https://github.com/puppetlabs/puppetlabs-apache/issues/2261
7-
unless os[:family] == 'redhat' && os[:release].to_i == 9
8-
describe 'apache::mod::php class', if: mod_supported_on_platform?('apache::mod::php') do
9-
context 'default php config' do
10-
pp = <<-MANIFEST
11-
class { 'apache':
12-
mpm_module => 'prefork',
13-
}
14-
class { 'apache::mod::php': }
15-
apache::vhost { 'php.example.com':
16-
port => 80,
17-
docroot => '#{apache_hash['doc_root']}/php',
18-
}
19-
host { 'php.example.com': ip => '127.0.0.1', }
20-
file { '#{apache_hash['doc_root']}/php/index.php':
21-
ensure => file,
22-
content => "<?php phpinfo(); ?>\\n",
23-
}
24-
MANIFEST
25-
it 'succeeds in puppeting php' do
26-
apply_manifest(pp, catch_failures: true)
27-
end
6+
describe 'apache::mod::php class', if: mod_supported_on_platform?('apache::mod::php') do
7+
context 'default php config' do
8+
pp = <<-MANIFEST
9+
class { 'apache':
10+
mpm_module => 'prefork',
11+
}
12+
class { 'apache::mod::php': }
13+
apache::vhost { 'php.example.com':
14+
port => 80,
15+
docroot => '#{apache_hash['doc_root']}/php',
16+
}
17+
host { 'php.example.com': ip => '127.0.0.1', }
18+
file { '#{apache_hash['doc_root']}/php/index.php':
19+
ensure => file,
20+
content => "<?php phpinfo(); ?>\\n",
21+
}
22+
MANIFEST
23+
it 'succeeds in puppeting php' do
24+
apply_manifest(pp, catch_failures: true)
25+
end
2826

29-
if os[:family] == 'debian' && os[:release] =~ %r{^9\.}
30-
describe file("#{apache_hash['mod_dir']}/php7.0.conf") do
31-
it { is_expected.to contain 'DirectoryIndex index.php' }
32-
end
33-
elsif os[:family] == 'debian' && os[:release] =~ %r{^10\.}
34-
describe file("#{apache_hash['mod_dir']}/php7.3.conf") do
35-
it { is_expected.to contain 'DirectoryIndex index.php' }
36-
end
37-
elsif os[:family] == 'debian' && os[:release] =~ %r{^11\.}
38-
describe file("#{apache_hash['mod_dir']}/php7.4.conf") do
39-
it { is_expected.to contain 'DirectoryIndex index.php' }
40-
end
41-
elsif os[:family] == 'ubuntu' && os[:release] == '18.04'
42-
describe file("#{apache_hash['mod_dir']}/php7.2.conf") do
43-
it { is_expected.to contain 'DirectoryIndex index.php' }
44-
end
45-
elsif os[:family] == 'ubuntu' && os[:release] == '20.04'
46-
describe file("#{apache_hash['mod_dir']}/php7.4.conf") do
47-
it { is_expected.to contain 'DirectoryIndex index.php' }
48-
end
49-
elsif os[:family] == 'redhat' && os[:release] =~ %r{^(9)\b}
50-
describe file("#{apache_hash['mod_dir']}/php.conf") do
51-
it { is_expected.to contain 'DirectoryIndex index.php' }
52-
end
53-
elsif os[:family] == 'redhat' && os[:release] =~ %r{^(8)\b}
54-
describe file("#{apache_hash['mod_dir']}/php7.conf") do
55-
it { is_expected.to contain 'DirectoryIndex index.php' }
56-
end
57-
elsif os[:family] == 'sles' && os[:release].to_i >= 15
58-
describe file("#{apache_hash['mod_dir']}/php7.conf") do
59-
it { is_expected.to contain 'DirectoryIndex index.php' }
60-
end
61-
else
62-
describe file("#{apache_hash['mod_dir']}/php5.conf") do
63-
it { is_expected.to contain 'DirectoryIndex index.php' }
64-
end
27+
if os[:family] == 'debian' && os[:release] =~ %r{^9\.}
28+
describe file("#{apache_hash['mod_dir']}/php7.0.conf") do
29+
it { is_expected.to contain 'DirectoryIndex index.php' }
30+
end
31+
elsif os[:family] == 'debian' && os[:release] =~ %r{^10\.}
32+
describe file("#{apache_hash['mod_dir']}/php7.3.conf") do
33+
it { is_expected.to contain 'DirectoryIndex index.php' }
34+
end
35+
elsif os[:family] == 'debian' && os[:release] =~ %r{^11\.}
36+
describe file("#{apache_hash['mod_dir']}/php7.4.conf") do
37+
it { is_expected.to contain 'DirectoryIndex index.php' }
38+
end
39+
elsif os[:family] == 'ubuntu' && os[:release] == '18.04'
40+
describe file("#{apache_hash['mod_dir']}/php7.2.conf") do
41+
it { is_expected.to contain 'DirectoryIndex index.php' }
42+
end
43+
elsif os[:family] == 'ubuntu' && os[:release] == '20.04'
44+
describe file("#{apache_hash['mod_dir']}/php7.4.conf") do
45+
it { is_expected.to contain 'DirectoryIndex index.php' }
46+
end
47+
elsif os[:family] == 'redhat' && os[:release] =~ %r{^(8)\b}
48+
describe file("#{apache_hash['mod_dir']}/php7.conf") do
49+
it { is_expected.to contain 'DirectoryIndex index.php' }
50+
end
51+
elsif os[:family] == 'sles' && os[:release].to_i >= 15
52+
describe file("#{apache_hash['mod_dir']}/php7.conf") do
53+
it { is_expected.to contain 'DirectoryIndex index.php' }
54+
end
55+
else
56+
describe file("#{apache_hash['mod_dir']}/php5.conf") do
57+
it { is_expected.to contain 'DirectoryIndex index.php' }
6558
end
6659
end
60+
end
6761

68-
context 'custom extensions, php_flag, php_value, php_admin_flag, and php_admin_value' do
69-
pp = <<-MANIFEST
70-
class { 'apache':
71-
mpm_module => 'prefork',
72-
}
73-
class { 'apache::mod::php':
74-
extensions => ['.php','.php5'],
62+
context 'custom extensions, php_flag, php_value, php_admin_flag, and php_admin_value' do
63+
pp = <<-MANIFEST
64+
class { 'apache':
65+
mpm_module => 'prefork',
7566
}
67+
class { 'apache::mod::php':
68+
extensions => ['.php','.php5'],
69+
}
7670
77-
apache::vhost { 'php.example.com':
78-
port => 80,
79-
docroot => '#{apache_hash['doc_root']}/php',
80-
php_values => { 'include_path' => '.:/usr/share/pear:/usr/bin/php', },
81-
php_flags => { 'display_errors' => 'on', },
82-
php_admin_values => { 'open_basedir' => '/var/www/php/:/usr/share/pear/', },
83-
php_admin_flags => { 'engine' => 'on', },
84-
}
85-
host { 'php.example.com': ip => '127.0.0.1', }
86-
file { '#{apache_hash['doc_root']}/php/index.php5':
87-
ensure => file,
88-
content => "<?php phpinfo(); ?>\\n",
89-
}
90-
MANIFEST
91-
it 'succeeds in puppeting php' do
92-
apply_manifest(pp, catch_failures: true)
93-
end
71+
apache::vhost { 'php.example.com':
72+
port => 80,
73+
docroot => '#{apache_hash['doc_root']}/php',
74+
php_values => { 'include_path' => '.:/usr/share/pear:/usr/bin/php', },
75+
php_flags => { 'display_errors' => 'on', },
76+
php_admin_values => { 'open_basedir' => '/var/www/php/:/usr/share/pear/', },
77+
php_admin_flags => { 'engine' => 'on', },
78+
}
79+
host { 'php.example.com': ip => '127.0.0.1', }
80+
file { '#{apache_hash['doc_root']}/php/index.php5':
81+
ensure => file,
82+
content => "<?php phpinfo(); ?>\\n",
83+
}
84+
MANIFEST
85+
it 'succeeds in puppeting php' do
86+
apply_manifest(pp, catch_failures: true)
87+
end
9488

95-
describe file("#{apache_hash['vhost_dir']}/25-php.example.com.conf") do
96-
it { is_expected.to contain ' php_flag display_errors on' }
97-
it { is_expected.to contain ' php_value include_path ".:/usr/share/pear:/usr/bin/php"' }
98-
it { is_expected.to contain ' php_admin_flag engine on' }
99-
it { is_expected.to contain ' php_admin_value open_basedir /var/www/php/:/usr/share/pear/' }
100-
end
89+
describe file("#{apache_hash['vhost_dir']}/25-php.example.com.conf") do
90+
it { is_expected.to contain ' php_flag display_errors on' }
91+
it { is_expected.to contain ' php_value include_path ".:/usr/share/pear:/usr/bin/php"' }
92+
it { is_expected.to contain ' php_admin_flag engine on' }
93+
it { is_expected.to contain ' php_admin_value open_basedir /var/www/php/:/usr/share/pear/' }
10194
end
10295
end
10396
end

0 commit comments

Comments
 (0)