-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
(MODULES-8107) - Support added for Ubuntu 18.04. #1850
Conversation
@@ -354,7 +381,7 @@ | |||
$secpcrematchlimit = 1500 | |||
$secpcrematchlimitrecursion = 1500 | |||
$modsec_secruleengine = 'On' | |||
if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0 { | |||
if ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0) or ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '18.04') >= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes me think a helper function in stdlib could useful: if os_version_gt('Debian', '9') or os_version_gt('Ubuntu', '18.04') {
. Might write up a patch for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Wheezy is not mentioned in metadata.json you could simplify just static variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the version case statement, just static variables now
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '16.04') || | ||
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8') || | ||
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') | ||
unless (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8') || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is essentially all supported distros in the Debian osfamily per metadata.json, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is now checking if the os family is debian
end | ||
end | ||
expected_two = if (fact('operatingsystem') == 'Ubuntu') || | ||
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8') || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also all supported Debian distros?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
spec/classes/dev_spec.rb
Outdated
it { is_expected.to contain_class('apache::params') } | ||
it { is_expected.to contain_package('httpd-devel') } | ||
end | ||
when 'FreeBSD' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and Gentoo can be folded into the base context
spec/classes/dev_spec.rb
Outdated
} | ||
case facts[:os]['name'] | ||
when 'Debian' | ||
context 'on a Debian OS' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already know this context so it's redundant (see line 4). I won't repeat this for every spec, but it's a repeated pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the redundant context's
3202b12
to
cb2f0b3
Compare
@ekohl Thank you for the review, think I've resolved all of your comment's if you have the time to take another look? |
spec/acceptance/vhost_spec.rb
Outdated
@@ -1568,7 +1568,8 @@ class { 'apache': } | |||
# Limit testing to Debian, since Centos does not have fastcgi package. | |||
case fact('osfamily') | |||
when 'Debian' | |||
next if fact('operatingsystemmajrelease') == '9' # Debian 9 does not support this fastcgi | |||
next if (fact('operatingsystemmajrelease') == '9') || (fact('operatingsystemmajrelease') == '18.04') # Debian 9/Ubuntu 18.04 does not support this fastcgi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also be written as ['9', '18.04'].include?(fact('operatingsystemmajrelease'))
. I'd also rewrite the whole case to a simple if fact('osfamily') == 'Debian' && !['9', '18.04'].include?(fact('operatingsystemmajrelease'))
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have done as you suggested, thanks for the code.
spec/classes/dev_spec.rb
Outdated
@@ -1,92 +1,39 @@ | |||
require 'spec_helper' | |||
|
|||
describe 'apache::dev', type: :class do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could remove the redundant type: class
while you're at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
spec/classes/dev_spec.rb
Outdated
it { is_expected.to contain_class('apache::params') } | ||
it { is_expected.to contain_package('httpd-devel') } | ||
when 'FreeBSD' | ||
it { is_expected.to contain_class('apache::params') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could also be pulled out of the case. It's not listed under Ubuntu, but I'm pretty sure that also contains the params class :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have pulled it out.
spec/classes/mod/fastcgi_spec.rb
Outdated
context 'with all defaults' do | ||
case facts[:os]['name'] | ||
when 'Debian' | ||
context 'on a Debian OS' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context is redundant, also specified at line 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed the unneeded context
spec/classes/mod/suphp_spec.rb
Outdated
case facts[:os]['family'] | ||
when 'Debian' | ||
# suphp has been declared EOL and is no longer supported on these modules | ||
if (facts[:os]['release']['major'].to_i < 16 && facts[:os]['name'] == 'Ubuntu') || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add an else condition to test it actually fails? There are also no distros listed in metadata that match these conditions so the content of this block is dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have just removed the section so it only runs on Redhat now.
spec/spec_helper_local.rb
Outdated
@@ -35,5 +35,5 @@ | |||
} | |||
end | |||
|
|||
it { is_expected.to compile.with_all_deps } | |||
# it { is_expected.to compile.with_all_deps } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still intended? If so, perhaps just remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed it.
spec/spec_helper_local.rb
Outdated
@@ -19,7 +19,7 @@ | |||
it { is_expected.to compile.with_all_deps } | |||
end | |||
|
|||
shared_examples 'a mod class, without including apache' do | |||
shared_context 'a mod class, without including apache' do | |||
let :facts do | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative: on_supported_os['debian-8-x86_64']
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ekohl Not entirely sure what you mean in this comment??? Could you explain a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use rspec-facter-db explicitly to avoid duplication:
let(:facts) { on_supported_os['debian-8-x86_64'] }
cb2f0b3
to
bd45628
Compare
manifests/mod/security.pp
Outdated
apache::security::rule_link { $activated_rules: } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trivial nit: this line could be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@@ -354,7 +381,7 @@ | |||
$secpcrematchlimit = 1500 | |||
$secpcrematchlimitrecursion = 1500 | |||
$modsec_secruleengine = 'On' | |||
if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0 { | |||
if ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0) or ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '18.04') >= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec/acceptance/mod_php_spec.rb
Outdated
it { is_expected.to contain '# somecontent' } | ||
end | ||
|
||
path = if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04') || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that above it's a long if/else tree where here we define a path. Below it's duplicated. Perhaps it should be a let(:php_config_path)
block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swapped to a let
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Threw an error so swapped to a before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't work either. Have just reverted it to how it was.
spec/acceptance/mod_suphp_spec.rb
Outdated
# As of 2013 suphp was declared EOL by it's creators and as such support for it has been removed from Ubunto 15.10/Debian 8 onward. | ||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=738133 | ||
# https://www.howtoforge.com/tutorial/perfect-server-debian-8-jessie-apache-bind-dovecot-ispconfig-3/2/#-install-suphp-optional-not-recommended | ||
describe 'apache::mod::suphp class', if: (fact('operatingsystem') == 'Ubuntu' && (fact('operatingsystemmajrelease') < '15.10')) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These distros aren't listed in metadata.json so I wonder if it's even relevant to keep this. On the other hand, the unit tests are still run on RH so you might switch it to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was hesitant on outright removing, but what the hell.
spec/acceptance/vhost_spec.rb
Outdated
@@ -964,7 +964,7 @@ class { 'apache': } | |||
describe file($ports_file) do | |||
it { is_expected.to be_file } | |||
if fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') == '7' || | |||
fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') =~ %r{(14\.04|16\.04)} || | |||
fact('operatingsystem') == 'Ubuntu' || | |||
fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8' || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat unrelated, but this is all the Debian versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checks if osfamily is debian now.
spec/classes/mod/suphp_spec.rb
Outdated
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
is_pe: false, | ||
} | ||
context 'on a RedHat OS' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a duplicated context from line 7 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
spec/defines/modsec_link_spec.rb
Outdated
it { is_expected.to compile.with_all_deps } | ||
case facts[:os]['family'] | ||
when 'RedHat' | ||
context 'on RedHat based systems' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated context :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed :)
ab8e3d2
to
c3735a3
Compare
spec/acceptance/mod_php_spec.rb
Outdated
end | ||
end | ||
|
||
context 'provide content and template config file' do | ||
# does the following even makes sense? Why do we hardcode the php5 template? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. If you remove content
the perhaps it can be a test to override the template parameter but currently it doesn't do that. Now it's a duplicate of the provide custom config file
test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was originally a comment from bastelfreak, but looking it over I can't see one good reason for it to be there.
spec/defines/fastcgi_server_spec.rb
Outdated
} | ||
case facts[:os]['family'] | ||
when 'RedHat' | ||
context 'on RedHat based systems' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed Duplication
spec/defines/fastcgi_server_spec.rb
Outdated
case facts[:os]['family'] | ||
when 'RedHat' | ||
context 'on RedHat based systems' do | ||
it { is_expected.to contain_class('apache') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This expectation can be pulled out of the case statement. An alternative is to put the variable path
assignment in a case statement and have the same expectations for all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top two it's have been moved outside the case
9766e17
to
f9f0773
Compare
spec/acceptance/mod_dav_svn_spec.rb
Outdated
@@ -1,7 +1,7 @@ | |||
require 'spec_helper_acceptance' | |||
require_relative './version.rb' | |||
|
|||
describe 'apache::mod::dav_svn class', unless: (fact('operatingsystem') == 'OracleLinux' && fact('operatingsystemmajrelease') == '7') do | |||
describe 'apache::mod::dav_svn class', unless: stdlib::os_version_gte('OracleLinux', '7') do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work? Can you refer to module functions in acceptance tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, got too caught up in the new function. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could introduce an equivalent spec helper function. Shouldn't be too hard and it does clean up the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the way you think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just removed it from the test's. Kept running into errors during the compile process.
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}") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now matches the Ubuntu case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed the case
spec/acceptance/mod_php_spec.rb
Outdated
if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04') || | ||
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') | ||
describe file("#{$mod_dir}/php7.0.conf") do | ||
if stdlib:os_version_gte('Ubuntu', '18.04') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a :
here
spec/acceptance/mod_php_spec.rb
Outdated
end | ||
elsif fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04' | ||
|
||
if stdlib:os_version_gte('Ubuntu', '18.04') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a :
4043488
to
75f0bc6
Compare
manifests/mod/dav_svn.pp
Outdated
@@ -4,7 +4,7 @@ | |||
Class['::apache::mod::dav'] -> Class['::apache::mod::dav_svn'] | |||
include ::apache | |||
include ::apache::mod::dav | |||
if($::operatingsystem == 'SLES' and $::operatingsystemmajrelease < '12'){ | |||
unless stdlib::os_version_gte('SLES', '12') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't namespace the function so it should be on the top level. Perhaps it should be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the method seems to be causing error's on the unit test's :(
Failure/Error: it { is_expected.to contain_class('apache::params') }
Puppet::PreformattedError:
Evaluation Error: Unknown function: 'stdlib::os_version_gte'. (file: /Users/david.swan/GitHub/puppetlabs-apache/spec/fixtures/modules/apache/manifests/mod/fcgid.pp, line: 5, column: 6) on node david.swan-c02l57z6fft1
Might have to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call os_version_gte
(without stdlib::
) I'd expect it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh that worked, though had to undo one of them, I'd accidentally swapped out an OS family.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it's throwing an unknown function error when the acceptance test's are run, tried a few things but nothing seemed to get rid of it so I just ripped it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably because the acceptance test installs a released version. Since the function is not yet in a released version, it's a problem. It'd also be needed to raise the minimum version in metadata.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, that sounds right.
Apologies, but at this point I think I'm just gonna go ahead without it since it only resolved down to a single use in the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, that totally makes sense. I often also don't want to depend on the very latest version of a very common module (which stdlib absolutely is) to give users a chance to upgrade. So I'm fine with leaving the cleanup to a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IS everything else good with my pr?? Any more changes you think are needed/beneficial???
7ee8277
to
30f87bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm done and this is ready to be merged :)
when 'Debian' | ||
conf_file = "#{$mod_dir}/passenger.conf" | ||
load_file = "#{$mod_dir}/zpassenger.load" | ||
describe 'apache::mod::passenger class', if: fact('osfamily') == 'Debian' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be nice if there were acceptance tests for RH since it's something we do rely on but right now the tests aren't executed for RH anyway, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, I looked through the history of the file and found that they were removed by @tphoney
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
installing the various mods in redhat is painful, hence the removal
Has passed experimental adhoc pipeline |
30f87bf
to
27406c2
Compare
PR made to finialize work started by community member bastelfreak, (puppetlabs#1809). Includes work done to migrate spec classes tests to rspec-puppet-facts. Co-authored-by: Tim Meusel <[email protected]>
27406c2
to
1ff11b0
Compare
Merged 👍 Super good job to everyone involved! |
Big thanks to both @bastelfreak, for doing the heavy lifting on getting this work done and @ekohl, for his his excellent reviews. |
PR made to finialize work started by community member bastelfreak, (#1809).
Includes work done to migrate spec classes tests to rspec-puppet-facts.