Skip to content

Commit 7ee8277

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 b41a0ff commit 7ee8277

23 files changed

+3104
-3744
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 & 89 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 */
@@ -148,36 +125,8 @@ class { 'apache::mod::passenger': }
148125

149126
describe file(conf_file) do
150127
it { is_expected.to contain %(PassengerRoot "#{passenger_root}") }
151-
case fact('operatingsystem')
152-
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
166-
when 'Debian'
167-
case fact('operatingsystemmajrelease')
168-
when '8'
169-
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
170-
it { is_expected.not_to contain '/PassengerRuby/' }
171-
when '9'
172-
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
173-
it { is_expected.not_to contain '/PassengerRuby/' }
174-
else
175-
# Includes wheezy
176-
# This may or may not work on Debian releases other than the above
177-
it { is_expected.to contain %(PassengerRuby "#{passenger_ruby}) }
178-
it { is_expected.not_to contain '/PassengerDefaultRuby/' }
179-
end
180-
end
128+
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
129+
it { is_expected.not_to contain '/PassengerRuby/' }
181130
end
182131
# rubocop:enable RSpec/RepeatedExample
183132

@@ -188,10 +137,7 @@ class { 'apache::mod::passenger': }
188137
expected_one = [%r{Apache processes}, %r{Nginx processes}, %r{Passenger processes}]
189138
# passenger-memory-stats output on newer Debian/Ubuntu verions do not contain
190139
# 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')
140+
unless fact('osfamily') == 'Debian'
195141
expected_one << [%r{### Processes: [0-9]+}, %r{### Total private dirty RSS: [0-9\.]+ MB}]
196142
end
197143
it 'outputs status via passenger-memory-stats #stdout' do
@@ -207,34 +153,27 @@ class { 'apache::mod::passenger': }
207153
end
208154
end
209155

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
156+
it 'outputs status via passenger-status #General information' do
157+
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
158+
# spacing may vary
159+
expect(r.stdout).to match(%r{[\-]+ General information [\-]+})
218160
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
161+
end
162+
expected_two = if fact('osfamily') == 'Debian'
163+
[%r{Max pool size[ ]+: [0-9]+}, %r{Processes[ ]+: [0-9]+}, %r{Requests in top-level queue[ ]+: [0-9]+}]
164+
else
165+
[%r{max[ ]+= [0-9]+}, %r{count[ ]+= [0-9]+}, %r{active[ ]+= [0-9]+}, %r{inactive[ ]+= [0-9]+}, %r{Waiting on global queue: [0-9]+}]
166+
end
167+
it 'outputs status via passenger-status #stdout' do
168+
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
169+
expected_two.each do |expect|
170+
expect(r.stdout).to match(expect)
232171
end
233172
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
173+
end
174+
it 'outputs status via passenger-status #exit_code' do
175+
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
176+
expect(r.exit_code).to eq(0)
238177
end
239178
end
240179

spec/acceptance/mod_php_spec.rb

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
unless fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12'
55
describe 'apache::mod::php class' do
66
context 'default php config' do
7+
if ['16.04', '18.04'].include?(fact('operatingsystemmajrelease'))
8+
# this policy defaults to 101. it prevents newly installed services from starting
9+
# it is useful for containers, it prevents new processes during 'docker build'
10+
# but we actually want to test the services and this should not behave like docker
11+
# but like a normal operating system
12+
13+
# without this apache fails to start -> installation of mod-php-something fails because it reloads apache to enable the module
14+
# exit codes are documented at https://askubuntu.com/a/365912. Default for docker images is 101
15+
shell("if [ -a '/usr/sbin/policy-rc.d' ]; then sed -i 's/^exit.*/exit 0/' /usr/sbin/policy-rc.d; fi")
16+
end
17+
if fact('operatingsystemmajrelease') == '18.04'
18+
# apache helper script has a bug which prevents the installation of certain apache modules
19+
# https://bugs.launchpad.net/ubuntu/+source/php7.2/+bug/1771934
20+
# https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1782806
21+
pp1 = "class { 'apache': mpm_module => 'prefork',}"
22+
it 'succeeds in installing apache' do
23+
apply_manifest(pp1, catch_failures: true)
24+
end
25+
it 'fixes the broken apache2 helper from Ubuntu 18.04' do
26+
shell("sed -i 's|a2query -m \"$mpm_$MPM\"|a2query -m \"mpm_$MPM\"|' /usr/share/apache2/apache2-maintscript-helper")
27+
end
28+
end
729
pp = <<-MANIFEST
830
class { 'apache':
931
mpm_module => 'prefork',
@@ -37,6 +59,10 @@ class { 'apache::mod::php': }
3759
describe file("#{$mod_dir}/php7.0.conf") do
3860
it { is_expected.to contain 'DirectoryIndex index.php' }
3961
end
62+
elsif fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04'
63+
describe file("#{$mod_dir}/php7.2.conf") do
64+
it { is_expected.to contain 'DirectoryIndex index.php' }
65+
end
4066
else
4167
describe file("#{$mod_dir}/php5.conf") do
4268
it { is_expected.to contain 'DirectoryIndex index.php' }
@@ -126,30 +152,8 @@ class {'apache::mod::php':
126152
describe file("#{$mod_dir}/php7.0.conf") do
127153
it { is_expected.to contain '# somecontent' }
128154
end
129-
else
130-
describe file("#{$mod_dir}/php5.conf") do
131-
it { is_expected.to contain '# somecontent' }
132-
end
133-
end
134-
end
135-
136-
context 'provide content and template config file' do
137-
pp = <<-MANIFEST
138-
class {'apache':
139-
mpm_module => 'prefork',
140-
}
141-
class {'apache::mod::php':
142-
content => '# somecontent',
143-
template => 'apache/mod/php5.conf.erb',
144-
}
145-
MANIFEST
146-
it 'succeeds in puppeting php' do
147-
apply_manifest(pp, catch_failures: true)
148-
end
149-
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
155+
elsif fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04'
156+
describe file("#{$mod_dir}/php7.2.conf") do
153157
it { is_expected.to contain '# somecontent' }
154158
end
155159
else

spec/acceptance/mod_security_spec.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class { 'apache::mod::security': }
7676
end
7777

7878
unless fact('operatingsystem') == 'SLES' ||
79-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
79+
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
80+
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
8081
it 'blocks query with SQL' do
8182
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
8283
end
@@ -116,7 +117,8 @@ class { 'apache::mod::security': }
116117
end
117118

118119
unless fact('operatingsystem') == 'SLES' ||
119-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
120+
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
121+
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
120122
it 'blocks query with SQL' do
121123
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
122124
end
@@ -179,7 +181,8 @@ class { 'apache::mod::security': }
179181
end
180182

181183
unless fact('operatingsystem') == 'SLES' ||
182-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
184+
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
185+
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
183186
it 'blocks query with SQL' do
184187
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
185188
end
@@ -246,7 +249,8 @@ class { 'apache::mod::security': }
246249
end
247250

248251
unless fact('operatingsystem') == 'SLES' ||
249-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
252+
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
253+
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
250254
it 'blocks query with SQL' do
251255
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
252256
end
@@ -313,7 +317,8 @@ class { 'apache::mod::security': }
313317
end
314318

315319
unless fact('operatingsystem') == 'SLES' ||
316-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
320+
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
321+
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
317322
it 'blocks query with SQL' do
318323
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
319324
end
@@ -380,7 +385,8 @@ class { 'apache::mod::security': }
380385
end
381386

382387
unless fact('operatingsystem') == 'SLES' ||
383-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
388+
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
389+
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
384390
it 'blocks query with SQL' do
385391
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
386392
end

0 commit comments

Comments
 (0)