Skip to content

Add Ubuntu 18.04 support #1809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
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
2 changes: 1 addition & 1 deletion manifests/mod/dav_svn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

::apache::mod { 'dav_svn': }

if $::osfamily == 'Debian' and ($::operatingsystemmajrelease != '6' and $::operatingsystemmajrelease != '10.04' and $::operatingsystemrelease != '10.04' and $::operatingsystemmajrelease != '16.04') {
if $::osfamily == 'Debian' and !($::operatingsystemmajrelease in ['16.04', '18.04']) {
$loadfile_name = undef
} else {
$loadfile_name = 'dav_svn_authz_svn.load'
Expand Down
3 changes: 3 additions & 0 deletions manifests/mod/fastcgi.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
if ($::osfamily == 'Redhat' and versioncmp($::operatingsystemrelease, '7.0') >= 0) {
fail('mod_fastcgi is no longer supported on el7 and above.')
}
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '18.04') >= 0) {
fail('mod_fastcgi is no longer supported on Ubuntu 18.04 and above. Please use mod_proxy_fcgi')
}
# Debian specifies it's fastcgi lib path, but RedHat uses the default value
# with no config file
$fastcgi_lib_path = $::apache::params::fastcgi_lib_path
Expand Down
6 changes: 5 additions & 1 deletion manifests/mod/security.pp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
}
}

unless $::operatingsystem == 'SLES' { apache::security::rule_link { $activated_rules: } }
# the rule setup on ubuntu 18.04 is completely different,
# the default rules used within this module aren't available
unless $::operatingsystem == 'SLES' or $facts['os']['release']['major'] == '18.04' {
apache::security::rule_link {$activated_rules: }
}

}
3 changes: 3 additions & 0 deletions manifests/mod/suphp.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class apache::mod::suphp (
){
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '18.04') >= 0) {
fail('suphp is no longer supported on Ubuntu 18.04 and above. Please use php-fpm')
}
include ::apache
::apache::mod { 'suphp': }

Expand Down
16 changes: 8 additions & 8 deletions manifests/mpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@
}
}

if $mpm == 'itk' and $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease == '14.04' {
if $mpm == 'itk' and ( ( $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease in ['16.04', '18.04'] ) or ( $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9.0.0') >= 0 ) ) {
$packagename = 'libapache2-mpm-itk'
} else {
$packagename = "apache2-mpm-${mpm}"
}

if $mpm == 'itk' and $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease in ['14.04', '18.04'] {
# workaround https://bugs.launchpad.net/ubuntu/+source/mpm-itk/+bug/1286882
exec {
'/usr/sbin/a2dismod mpm_event':
onlyif => '/usr/bin/test -e /etc/apache2/mods-enabled/mpm_event.load',
require => Package['httpd'],
before => Package['apache2-mpm-itk'],
before => Package[$packagename],
}
}

if $mpm == 'itk' and ( ( $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease == '16.04' ) or ( $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9.0.0') >= 0 ) ) {
$packagename = 'libapache2-mpm-itk'
} else {
$packagename = "apache2-mpm-${mpm}"
}

if versioncmp($apache_version, '2.4') < 0 or $mpm == 'itk' {
package { $packagename:
ensure => present,
Expand Down
27 changes: 27 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,33 @@
'wsgi' => 'libapache2-mod-wsgi',
'xsendfile' => 'libapache2-mod-xsendfile',
}
} elsif $facts['os']['release']['major'] == '18.04' {
# major.minor version used since Debian stretch and Ubuntu Xenial
$php_version = '7.2' # different to Ubuntu 16.04
# fastcgi and suphp got removed from #mod_packages, they aren't supported anymore
$mod_packages = {
'auth_cas' => 'libapache2-mod-auth-cas',
'auth_kerb' => 'libapache2-mod-auth-kerb',
'auth_gssapi' => 'libapache2-mod-auth-gssapi',
'auth_mellon' => 'libapache2-mod-auth-mellon',
'authnz_pam' => 'libapache2-mod-authnz-pam',
'dav_svn' => 'libapache2-mod-svn', # different to Ubuntu16.04
'fcgid' => 'libapache2-mod-fcgid',
'geoip' => 'libapache2-mod-geoip',
'intercept_form_submit' => 'libapache2-mod-intercept-form-submit',
'lookup_identity' => 'libapache2-mod-lookup-identity',
'nss' => 'libapache2-mod-nss',
'pagespeed' => 'mod-pagespeed-stable',
'passenger' => 'libapache2-mod-passenger',
'perl' => 'libapache2-mod-perl2',
'phpXXX' => 'libapache2-mod-phpXXX',
'python' => 'libapache2-mod-python',
'rpaf' => 'libapache2-mod-rpaf',
'security' => 'libapache2-mod-security2',
'shib2' => 'libapache2-mod-shib2',
'wsgi' => 'libapache2-mod-wsgi',
'xsendfile' => 'libapache2-mod-xsendfile',
}
} else {
# major.minor version used since Debian stretch and Ubuntu Xenial
$php_version = '7.0'
Expand Down
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04",
"16.04"
"16.04",
"18.04"
]
}
],
Expand Down
107 changes: 47 additions & 60 deletions spec/acceptance/mod_passenger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,8 @@

case fact('operatingsystem')
when 'Ubuntu'
case fact('lsbdistrelease')
when '14.04'
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
passenger_default_ruby = '/usr/bin/ruby'
when '16.04'
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
passenger_default_ruby = '/usr/bin/ruby'
else
# Includes 10.04 and 12.04
# This may or may not work on Ubuntu releases other than the above
passenger_root = '/usr'
passenger_ruby = '/usr/bin/ruby'
end
passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
passenger_default_ruby = '/usr/bin/ruby'
when 'Debian'
case fact('lsbdistcodename')
when 'jessie'
Expand Down Expand Up @@ -113,12 +102,28 @@ class { 'apache::mod::passenger':
end
end
context 'default passenger config' do
pp = <<-MANIFEST
/* stock apache and mod_passenger */
class { 'apache': }
class { 'apache::mod::passenger': }
#{pp_rackapp}
MANIFEST
# We need to set passenger_instance_registry_dir on every sane distro
# with systemd. Systemd can force processes into a seperate/private
# tmpdir. This is the default for apache on Ubuntu 18.04. As a result,
# passenger CLI tools can't find the config/socket, which defaults to /tmp
# we enable it for ubuntu 16.04/18.04, centos7 and debian 9
pp = if ['7', '9', '16.04', '18.04'].include?(fact('operatingsystemmajrelease'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These magic numbers feel like a difficult to maintain/easy to break setup. Perhaps it should check for fact('service_provider') == 'systemd' instead? You could even do it in a pure puppet block:

$passenger_instance_registry_dir = $fact['service_provider'] == 'systemd' ?
  true    => '/var/run',
  default => undef,
}
class { 'apache': }
class { 'apache::mod::passenger':
  passenger_instance_registry_dir => $passenger_instance_registry_dir,
}

<<-MANIFEST
/* stock apache and mod_passenger */
class { 'apache': }
class { 'apache::mod::passenger':
passenger_instance_registry_dir => '/var/run',
}
#{pp_rackapp}
MANIFEST
else
<<-MANIFEST
/* stock apache and mod_passenger */
class { 'apache': }
class { 'apache::mod::passenger': }
#{pp_rackapp}
MANIFEST
end
it 'succeeds in puppeting passenger' do
apply_manifest(pp, catch_failures: true)
end
Expand All @@ -136,19 +141,8 @@ class { 'apache::mod::passenger': }
it { is_expected.to contain %(PassengerRoot "#{passenger_root}") }
case fact('operatingsystem')
when 'Ubuntu'
case fact('lsbdistrelease')
when '14.04'
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
it { is_expected.not_to contain '/PassengerRuby/' }
when '16.04'
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
it { is_expected.not_to contain '/PassengerRuby/' }
else
# Includes 10.04 and 12.04
# This may or may not work on Ubuntu releases other than the above
it { is_expected.to contain %(PassengerRuby "#{passenger_ruby}) }
it { is_expected.not_to contain '/PassengerDefaultRuby/' }
end
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
it { is_expected.not_to contain '/PassengerRuby/' }
when 'Debian'
case fact('lsbdistcodename')
when 'jessie'
Expand All @@ -171,10 +165,8 @@ class { 'apache::mod::passenger': }
expected_one = [%r{Apache processes}, %r{Nginx processes}, %r{Passenger processes}]
# passenger-memory-stats output on newer Debian/Ubuntu verions do not contain
# these two lines
unless (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04') ||
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '16.04') ||
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8')
expected_one << [%r{### Processes: [0-9]+}, %r{### Total private dirty RSS: [0-9\.]+ MB}]
unless fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8'
expected_one + [%r{### Processes: [0-9]+}, %r{### Total private dirty RSS: [0-9\.]+ MB}]
end
it 'outputs status via passenger-memory-stats #stdout' do
expected_one.each do |expect|
Expand All @@ -189,33 +181,28 @@ class { 'apache::mod::passenger': }
end
end

# passenger-status fails under stock ubuntu-server-12042-x64 + mod_passenger,
# even when the passenger process is successfully installed and running
unless fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '12.04'
it 'outputs status via passenger-status #General information' do
shell('PATH=/usr/bin:$PATH /usr/sbin/passenger-status') do |r|
# spacing may vary
expect(r.stdout).to match(%r{[\-]+ General information [\-]+})
end
it 'outputs status via passenger-status #General information' do
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
# spacing may vary
expect(r.stdout).to match(%r{[\-]+ General information [\-]+})
end
expected_two = if fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04' ||
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '16.04') ||
fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8'
[%r{Max pool size[ ]+: [0-9]+}, %r{Processes[ ]+: [0-9]+}, %r{Requests in top-level queue[ ]+: [0-9]+}]
else
[%r{max[ ]+= [0-9]+}, %r{count[ ]+= [0-9]+}, %r{active[ ]+= [0-9]+}, %r{inactive[ ]+= [0-9]+}, %r{Waiting on global queue: [0-9]+}]
end
it 'outputs status via passenger-status #stdout' do
shell('PATH=/usr/bin:$PATH /usr/sbin/passenger-status') do |r|
expected_two.each do |expect|
expect(r.stdout).to match(expect)
end
end
expected_two = if fact('operatingsystem') == 'Ubuntu' ||
fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8'
[%r{Max pool size[ ]+: [0-9]+}, %r{Processes[ ]+: [0-9]+}, %r{Requests in top-level queue[ ]+: [0-9]+}]
else
[%r{max[ ]+= [0-9]+}, %r{count[ ]+= [0-9]+}, %r{active[ ]+= [0-9]+}, %r{inactive[ ]+= [0-9]+}, %r{Waiting on global queue: [0-9]+}]
end
it 'outputs status via passenger-status #stdout' do
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
expected_two.each do |expect|
expect(r.stdout).to match(expect)
end
end
it 'outputs status via passenger-status #exit_code' do
shell('PATH=/usr/bin:$PATH /usr/sbin/passenger-status') do |r|
expect(r.exit_code).to eq(0)
end
end
it 'outputs status via passenger-status #exit_code' do
shell('PATH=/usr/bin:$PATH PASSENGER_INSTANCE_REGISTRY_DIR=/var/run /usr/sbin/passenger-status') do |r|
expect(r.exit_code).to eq(0)
end
end

Expand Down
62 changes: 46 additions & 16 deletions spec/acceptance/mod_php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@
unless fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12'
describe 'apache::mod::php class' do
context 'default php config' do
if ['16.04', '18.04'].include?(fact('operatingsystemmajrelease'))
# this policy defaults to 101. it prevents newly installed services from starting
# it is useful for containers, it prevents new processes during 'docker build'
# but we actually want to test the services and this should not behave like docker
# but like a normal operating system

# without this apache fails to start -> installation of mod-php-something fails because it reloads apache to enable the module
# exit codes are documented at https://askubuntu.com/a/365912. Default for docker images is 101
shell("if [ -a '/usr/sbin/policy-rc.d' ]; then sed -i 's/^exit.*/exit 0/' /usr/sbin/policy-rc.d; fi")
end
if fact('operatingsystemmajrelease') == '18.04'
# apache helper script has a bug which prevents the installation of certain apache modules
# https://bugs.launchpad.net/ubuntu/+source/php7.2/+bug/1771934
# https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1782806
pp1 = "class { 'apache': mpm_module => 'prefork',}"
it 'succeeds in installing apache' do
apply_manifest(pp1, catch_failures: true)
end
it 'fixes the broken apache2 helper from Ubuntu 18.04' do
shell("sed -i 's|a2query -m \"$mpm_$MPM\"|a2query -m \"mpm_$MPM\"|' /usr/share/apache2/apache2-maintscript-helper")
end
end
pp = <<-MANIFEST
class { 'apache':
mpm_module => 'prefork',
Expand Down Expand Up @@ -36,6 +58,10 @@ class { 'apache::mod::php': }
describe file("#{$mod_dir}/php7.0.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif fact('operatingsystemmajrelease') == '18.04'
describe file("#{$mod_dir}/php7.2.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
else
describe file("#{$mod_dir}/php5.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
Expand Down Expand Up @@ -120,18 +146,21 @@ class {'apache::mod::php':
it 'succeeds in puppeting php' do
apply_manifest(pp, catch_failures: true)
end
if fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04'
describe file("#{$mod_dir}/php7.0.conf") do
it { is_expected.to contain '# somecontent' }
end
else
describe file("#{$mod_dir}/php5.conf") do
it { is_expected.to contain '# somecontent' }
end
path = if fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04'
"#{$mod_dir}/php7.0.conf"
elsif fact('operatingsystemmajrelease') == '18.04'
"#{$mod_dir}/php7.2.conf"
else
"#{$mod_dir}/php5.conf"
end
describe file(path) do
it { is_expected.to contain '# somecontent' }
end
end

context 'provide content and template config file' do
# does the following even makes sense? Why do we hardcode the php5 template?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd agree with you, not sure there's much point to this test

# I don't see what we gain from this test
pp = <<-MANIFEST
class {'apache':
mpm_module => 'prefork',
Expand All @@ -145,14 +174,15 @@ class {'apache::mod::php':
apply_manifest(pp, catch_failures: true)
end

if fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04'
describe file("#{$mod_dir}/php7.0.conf") do
it { is_expected.to contain '# somecontent' }
end
else
describe file("#{$mod_dir}/php5.conf") do
it { is_expected.to contain '# somecontent' }
end
path = if fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04'
"#{$mod_dir}/php7.0.conf"
elsif fact('operatingsystemmajrelease') == '18.04'
"#{$mod_dir}/php7.2.conf"
else
"#{$mod_dir}/php5.conf"
end
describe file(path) do
it { is_expected.to contain '# somecontent' }
end
end
end
Expand Down
Loading