Skip to content

Commit c3735a3

Browse files
committed
(MODULES-8107) - Support added for Ubuntu 18.04.
PR made to finialize work started by community member bastelfreak, (#1809). Includes work done to migrate spec classes tests to rspec-puppet-facts.
1 parent b21ec23 commit c3735a3

23 files changed

+3140
-3726
lines changed

manifests/mod/dav_svn.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
::apache::mod { 'dav_svn': }
1515

16-
if $::osfamily == 'Debian' and ! ($::operatingsystemmajrelease in ['6', '16.04', '9']) {
16+
if $::osfamily == 'Debian' and ! ($::operatingsystemmajrelease in ['6', '9', '16.04', '18.04']) {
1717
$loadfile_name = undef
1818
} else {
1919
$loadfile_name = 'dav_svn_authz_svn.load'

manifests/mod/fastcgi.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
if ($::osfamily == 'Redhat' and versioncmp($::operatingsystemrelease, '7.0') >= 0) {
44
fail('mod_fastcgi is no longer supported on el7 and above.')
55
}
6+
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '18.04') >= 0) {
7+
fail('mod_fastcgi is no longer supported on Ubuntu 18.04 and above. Please use mod_proxy_fcgi')
8+
}
69
# Debian specifies it's fastcgi lib path, but RedHat uses the default value
710
# with no config file
811
$fastcgi_lib_path = $::apache::params::fastcgi_lib_path

manifests/mod/security.pp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@
129129
}
130130

131131
# Debian 9 has a different rule setup
132-
unless $::operatingsystem == 'SLES' or ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0) {
132+
unless $::operatingsystem == 'SLES' or ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0) or ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '18.04') >= 0) {
133133
apache::security::rule_link { $activated_rules: }
134134
}
135-
136135
}

manifests/mod/suphp.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
class apache::mod::suphp (
22
){
3+
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '15.10') >= 0) or
4+
($facts['os']['name'] == 'Debian' and versioncmp($::operatingsystemrelease, '8') >= 0) {
5+
fail("suphp was declared EOL by it's creators as of 2013 and so is no longer supported on Ubuntu 15.10/Debian 8 and above. Please use php-fpm")
6+
}
37
include ::apache
48
::apache::mod { 'suphp': }
59

manifests/mpm.pp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
}
8383

8484
if $mpm == 'itk' {
85-
8685
if ( ( $::operatingsystem == 'Ubuntu' ) or ( ($::operatingsystem == 'Debian') and ( versioncmp($::operatingsystemrelease, '8.0.0') >= 0 ) ) ) {
8786
ensure_resource('exec', '/usr/sbin/a2dismod mpm_event', {
8887
onlyif => "/usr/bin/test -e ${apache::mod_enable_dir}/mpm_event.load",
@@ -98,7 +97,6 @@
9897
File[$::apache::mod_enable_dir],
9998
],
10099
}
101-
102100
}
103101

104102
if $mpm == 'prefork' {

manifests/params.pp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,33 @@
291291
'wsgi' => 'libapache2-mod-wsgi',
292292
'xsendfile' => 'libapache2-mod-xsendfile',
293293
}
294+
} elsif ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '18.04') >= 0) {
295+
# major.minor version used since Debian stretch and Ubuntu Xenial
296+
$php_version = '7.2' # different to Ubuntu 16.04
297+
# fastcgi and suphp got removed from #mod_packages, they aren't supported anymore
298+
$mod_packages = {
299+
'auth_cas' => 'libapache2-mod-auth-cas',
300+
'auth_kerb' => 'libapache2-mod-auth-kerb',
301+
'auth_gssapi' => 'libapache2-mod-auth-gssapi',
302+
'auth_mellon' => 'libapache2-mod-auth-mellon',
303+
'authnz_pam' => 'libapache2-mod-authnz-pam',
304+
'dav_svn' => 'libapache2-mod-svn', # different to Ubuntu16.04
305+
'fcgid' => 'libapache2-mod-fcgid',
306+
'geoip' => 'libapache2-mod-geoip',
307+
'intercept_form_submit' => 'libapache2-mod-intercept-form-submit',
308+
'lookup_identity' => 'libapache2-mod-lookup-identity',
309+
'nss' => 'libapache2-mod-nss',
310+
'pagespeed' => 'mod-pagespeed-stable',
311+
'passenger' => 'libapache2-mod-passenger',
312+
'perl' => 'libapache2-mod-perl2',
313+
'phpXXX' => 'libapache2-mod-phpXXX',
314+
'python' => 'libapache2-mod-python',
315+
'rpaf' => 'libapache2-mod-rpaf',
316+
'security' => 'libapache2-mod-security2',
317+
'shib2' => 'libapache2-mod-shib2',
318+
'wsgi' => 'libapache2-mod-wsgi',
319+
'xsendfile' => 'libapache2-mod-xsendfile',
320+
}
294321
} else {
295322
# major.minor version used since Debian stretch and Ubuntu Xenial
296323
$php_version = '7.0'
@@ -354,7 +381,7 @@
354381
$secpcrematchlimit = 1500
355382
$secpcrematchlimitrecursion = 1500
356383
$modsec_secruleengine = 'On'
357-
if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0 {
384+
if ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0) or ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '18.04') >= 0) {
358385
$modsec_default_rules = [
359386
'crawlers-user-agents.data',
360387
'iis-errors.data',

metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
{
6666
"operatingsystem": "Ubuntu",
6767
"operatingsystemrelease": [
68-
"14.04",
69-
"16.04"
68+
"16.04",
69+
"18.04"
7070
]
7171
}
7272
],

spec/acceptance/mod_passenger_spec.rb

Lines changed: 28 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,8 @@
77
conf_file = "#{$mod_dir}/passenger.conf"
88
load_file = "#{$mod_dir}/zpassenger.load"
99

10-
case fact('operatingsystem')
11-
when 'Ubuntu'
12-
case fact('lsbdistrelease')
13-
when '14.04'
14-
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
15-
passenger_default_ruby = '/usr/bin/ruby'
16-
when '16.04'
17-
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
18-
passenger_default_ruby = '/usr/bin/ruby'
19-
else
20-
# Includes 10.04 and 12.04
21-
# This may or may not work on Ubuntu releases other than the above
22-
passenger_root = '/usr'
23-
passenger_ruby = '/usr/bin/ruby'
24-
end
25-
when 'Debian'
26-
case fact('operatingsystemmajrelease')
27-
when '8'
28-
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
29-
passenger_default_ruby = '/usr/bin/ruby'
30-
when '9'
31-
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
32-
passenger_default_ruby = '/usr/bin/ruby'
33-
else
34-
# Includes wheezy
35-
# This may or may not work on Debian releases other than the above
36-
passenger_root = '/usr'
37-
passenger_ruby = '/usr/bin/ruby'
38-
end
39-
end
10+
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
11+
passenger_default_ruby = '/usr/bin/ruby'
4012

4113
passenger_module_path = '/usr/lib/apache2/modules/mod_passenger.so'
4214
rackapp_user = 'www-data'
@@ -116,6 +88,11 @@ class { 'apache::mod::passenger':
11688
end
11789
end
11890
context 'default passenger config' do
91+
# We need to set passenger_instance_registry_dir on every sane distro
92+
# with systemd. Systemd can force processes into a seperate/private
93+
# tmpdir. This is the default for apache on Ubuntu 18.04. As a result,
94+
# passenger CLI tools can't find the config/socket, which defaults to /tmp
95+
# we enable it for ubuntu 16.04/18.04, centos7 and debian 9
11996
pp = if ['7', '9', '16.04', '18.04'].include?(fact('operatingsystemmajrelease'))
12097
<<-MANIFEST
12198
/* stock apache and mod_passenger */
@@ -150,19 +127,8 @@ class { 'apache::mod::passenger': }
150127
it { is_expected.to contain %(PassengerRoot "#{passenger_root}") }
151128
case fact('operatingsystem')
152129
when 'Ubuntu'
153-
case fact('lsbdistrelease')
154-
when '14.04'
155-
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
156-
it { is_expected.not_to contain '/PassengerRuby/' }
157-
when '16.04'
158-
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
159-
it { is_expected.not_to contain '/PassengerRuby/' }
160-
else
161-
# Includes 10.04 and 12.04
162-
# This may or may not work on Ubuntu releases other than the above
163-
it { is_expected.to contain %(PassengerRuby "#{passenger_ruby}) }
164-
it { is_expected.not_to contain '/PassengerDefaultRuby/' }
165-
end
130+
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
131+
it { is_expected.not_to contain '/PassengerRuby/' }
166132
when 'Debian'
167133
case fact('operatingsystemmajrelease')
168134
when '8'
@@ -188,10 +154,7 @@ class { 'apache::mod::passenger': }
188154
expected_one = [%r{Apache processes}, %r{Nginx processes}, %r{Passenger processes}]
189155
# passenger-memory-stats output on newer Debian/Ubuntu verions do not contain
190156
# these two lines
191-
unless (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04') ||
192-
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '16.04') ||
193-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8') ||
194-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
157+
unless fact('osfamily') == 'Debian'
195158
expected_one << [%r{### Processes: [0-9]+}, %r{### Total private dirty RSS: [0-9\.]+ MB}]
196159
end
197160
it 'outputs status via passenger-memory-stats #stdout' do
@@ -207,34 +170,27 @@ class { 'apache::mod::passenger': }
207170
end
208171
end
209172

210-
# passenger-status fails under stock ubuntu-server-12042-x64 + mod_passenger,
211-
# even when the passenger process is successfully installed and running
212-
unless fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '12.04'
213-
it 'outputs status via passenger-status #General information' do
214-
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
215-
# spacing may vary
216-
expect(r.stdout).to match(%r{[\-]+ General information [\-]+})
217-
end
173+
it 'outputs status via passenger-status #General information' do
174+
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
175+
# spacing may vary
176+
expect(r.stdout).to match(%r{[\-]+ General information [\-]+})
218177
end
219-
expected_two = if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04') ||
220-
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '16.04') ||
221-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8') ||
222-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
223-
[%r{Max pool size[ ]+: [0-9]+}, %r{Processes[ ]+: [0-9]+}, %r{Requests in top-level queue[ ]+: [0-9]+}]
224-
else
225-
[%r{max[ ]+= [0-9]+}, %r{count[ ]+= [0-9]+}, %r{active[ ]+= [0-9]+}, %r{inactive[ ]+= [0-9]+}, %r{Waiting on global queue: [0-9]+}]
226-
end
227-
it 'outputs status via passenger-status #stdout' do
228-
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
229-
expected_two.each do |expect|
230-
expect(r.stdout).to match(expect)
231-
end
178+
end
179+
expected_two = if fact('osfamily') == 'Debian'
180+
[%r{Max pool size[ ]+: [0-9]+}, %r{Processes[ ]+: [0-9]+}, %r{Requests in top-level queue[ ]+: [0-9]+}]
181+
else
182+
[%r{max[ ]+= [0-9]+}, %r{count[ ]+= [0-9]+}, %r{active[ ]+= [0-9]+}, %r{inactive[ ]+= [0-9]+}, %r{Waiting on global queue: [0-9]+}]
183+
end
184+
it 'outputs status via passenger-status #stdout' do
185+
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
186+
expected_two.each do |expect|
187+
expect(r.stdout).to match(expect)
232188
end
233189
end
234-
it 'outputs status via passenger-status #exit_code' do
235-
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
236-
expect(r.exit_code).to eq(0)
237-
end
190+
end
191+
it 'outputs status via passenger-status #exit_code' do
192+
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
193+
expect(r.exit_code).to eq(0)
238194
end
239195
end
240196

spec/acceptance/mod_php_spec.rb

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,43 @@
11
require 'spec_helper_acceptance'
22
require_relative './version.rb'
33

4+
php_config_path = ''
45
unless fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12'
56
describe 'apache::mod::php class' do
7+
before(:all) do
8+
php_config_path = if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04') ||
9+
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
10+
"#{$mod_dir}/php7.0.conf"
11+
elsif fact('operatingsystemmajrelease') == '18.04'
12+
"#{$mod_dir}/php7.2.conf"
13+
else
14+
"#{$mod_dir}/php5.conf"
15+
end
16+
end
17+
618
context 'default php config' do
19+
if ['16.04', '18.04'].include?(fact('operatingsystemmajrelease'))
20+
# this policy defaults to 101. it prevents newly installed services from starting
21+
# it is useful for containers, it prevents new processes during 'docker build'
22+
# but we actually want to test the services and this should not behave like docker
23+
# but like a normal operating system
24+
25+
# without this apache fails to start -> installation of mod-php-something fails because it reloads apache to enable the module
26+
# exit codes are documented at https://askubuntu.com/a/365912. Default for docker images is 101
27+
shell("if [ -a '/usr/sbin/policy-rc.d' ]; then sed -i 's/^exit.*/exit 0/' /usr/sbin/policy-rc.d; fi")
28+
end
29+
if fact('operatingsystemmajrelease') == '18.04'
30+
# apache helper script has a bug which prevents the installation of certain apache modules
31+
# https://bugs.launchpad.net/ubuntu/+source/php7.2/+bug/1771934
32+
# https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1782806
33+
pp1 = "class { 'apache': mpm_module => 'prefork',}"
34+
it 'succeeds in installing apache' do
35+
apply_manifest(pp1, catch_failures: true)
36+
end
37+
it 'fixes the broken apache2 helper from Ubuntu 18.04' do
38+
shell("sed -i 's|a2query -m \"$mpm_$MPM\"|a2query -m \"mpm_$MPM\"|' /usr/share/apache2/apache2-maintscript-helper")
39+
end
40+
end
741
pp = <<-MANIFEST
842
class { 'apache':
943
mpm_module => 'prefork',
@@ -37,6 +71,10 @@ class { 'apache::mod::php': }
3771
describe file("#{$mod_dir}/php7.0.conf") do
3872
it { is_expected.to contain 'DirectoryIndex index.php' }
3973
end
74+
elsif fact('operatingsystemmajrelease') == '18.04'
75+
describe file("#{$mod_dir}/php7.2.conf") do
76+
it { is_expected.to contain 'DirectoryIndex index.php' }
77+
end
4078
else
4179
describe file("#{$mod_dir}/php5.conf") do
4280
it { is_expected.to contain 'DirectoryIndex index.php' }
@@ -121,19 +159,15 @@ class {'apache::mod::php':
121159
it 'succeeds in puppeting php' do
122160
apply_manifest(pp, catch_failures: true)
123161
end
124-
if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04') ||
125-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
126-
describe file("#{$mod_dir}/php7.0.conf") do
127-
it { is_expected.to contain '# somecontent' }
128-
end
129-
else
130-
describe file("#{$mod_dir}/php5.conf") do
131-
it { is_expected.to contain '# somecontent' }
132-
end
162+
163+
describe file(php_config_path) do
164+
it { is_expected.to contain '# somecontent' }
133165
end
134166
end
135167

136168
context 'provide content and template config file' do
169+
# does the following even makes sense? Why do we hardcode the php5 template?
170+
# I don't see what we gain from this test
137171
pp = <<-MANIFEST
138172
class {'apache':
139173
mpm_module => 'prefork',
@@ -147,15 +181,8 @@ class {'apache::mod::php':
147181
apply_manifest(pp, catch_failures: true)
148182
end
149183

150-
if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04') ||
151-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
152-
describe file("#{$mod_dir}/php7.0.conf") do
153-
it { is_expected.to contain '# somecontent' }
154-
end
155-
else
156-
describe file("#{$mod_dir}/php5.conf") do
157-
it { is_expected.to contain '# somecontent' }
158-
end
184+
describe file(php_config_path) do
185+
it { is_expected.to contain '# somecontent' }
159186
end
160187
end
161188
end

0 commit comments

Comments
 (0)