Skip to content
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

Merged
merged 1 commit into from
Nov 30, 2018

Conversation

david22swan
Copy link
Member

PR made to finialize work started by community member bastelfreak, (#1809).
Includes work done to migrate spec classes tests to rspec-puppet-facts.

@@ -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) {
Copy link
Collaborator

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.

Copy link
Collaborator

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'
Copy link
Collaborator

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.

Copy link
Member Author

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') ||
Copy link
Collaborator

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?

Copy link
Member Author

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') ||
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

As above

it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_package('httpd-devel') }
end
when 'FreeBSD'
Copy link
Collaborator

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

}
case facts[:os]['name']
when 'Debian'
context 'on a Debian OS' do
Copy link
Collaborator

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.

Copy link
Member Author

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

@david22swan david22swan changed the title (MODULES-8107) - Support added for Ubuntu 18.04. (WIP) (MODULES-8107) - Support added for Ubuntu 18.04. Nov 22, 2018
@david22swan
Copy link
Member Author

david22swan commented Nov 23, 2018

@ekohl Thank you for the review, think I've resolved all of your comment's if you have the time to take another look?

@@ -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
Copy link
Collaborator

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')).

Copy link
Member Author

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.

@@ -1,92 +1,39 @@
require 'spec_helper'

describe 'apache::dev', type: :class do
Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed.

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') }
Copy link
Collaborator

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Have pulled it out.

context 'with all defaults' do
case facts[:os]['name']
when 'Debian'
context 'on a Debian OS' do
Copy link
Collaborator

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.

Copy link
Member Author

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

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') ||
Copy link
Collaborator

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.

Copy link
Member Author

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.

@@ -35,5 +35,5 @@
}
end

it { is_expected.to compile.with_all_deps }
# it { is_expected.to compile.with_all_deps }
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Have removed it.

@@ -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
{
Copy link
Collaborator

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'].

Copy link
Member Author

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?

Copy link
Collaborator

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'] }

apache::security::rule_link { $activated_rules: }

Copy link
Collaborator

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

Copy link
Member Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

it { is_expected.to contain '# somecontent' }
end

path = if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04') ||
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Swapped to a let

Copy link
Member Author

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

Copy link
Member Author

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.

# 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')) ||
Copy link
Collaborator

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.

Copy link
Member Author

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.

@@ -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' ||
Copy link
Collaborator

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.

Copy link
Member Author

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.

path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
is_pe: false,
}
context 'on a RedHat OS' do
Copy link
Collaborator

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed

it { is_expected.to compile.with_all_deps }
case facts[:os]['family']
when 'RedHat'
context 'on RedHat based systems' do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicated context :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed :)

@david22swan david22swan force-pushed the ubuntu1804 branch 2 times, most recently from ab8e3d2 to c3735a3 Compare November 26, 2018 11:49
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
Collaborator

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

Copy link
Member Author

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.

}
case facts[:os]['family']
when 'RedHat'
context 'on RedHat based systems' do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicated context

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed Duplication

case facts[:os]['family']
when 'RedHat'
context 'on RedHat based systems' do
it { is_expected.to contain_class('apache') }
Copy link
Collaborator

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.

Copy link
Member Author

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

@david22swan david22swan force-pushed the ubuntu1804 branch 3 times, most recently from 9766e17 to f9f0773 Compare November 26, 2018 14:44
@@ -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
Copy link
Collaborator

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?

Copy link
Member Author

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. :(

Copy link
Collaborator

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.

Copy link
Member Author

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 :)

Copy link
Member Author

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}") }
Copy link
Collaborator

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Have removed the case

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')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing a : here

end
elsif fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04'

if stdlib:os_version_gte('Ubuntu', '18.04')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing a :

@@ -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') {
Copy link
Collaborator

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?

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Member Author

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???

@david22swan david22swan force-pushed the ubuntu1804 branch 3 times, most recently from 7ee8277 to 30f87bf Compare November 29, 2018 11:51
@ekohl ekohl mentioned this pull request Nov 29, 2018
Copy link
Collaborator

@ekohl ekohl left a 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
Copy link
Collaborator

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?

Copy link
Member Author

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

Copy link
Contributor

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

@david22swan david22swan changed the title (WIP) (MODULES-8107) - Support added for Ubuntu 18.04. (MODULES-8107) - Support added for Ubuntu 18.04. Nov 29, 2018
@david22swan
Copy link
Member Author

screen shot 2018-11-29 at 4 53 53 pm

@david22swan
Copy link
Member Author

Has passed experimental adhoc pipeline

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 <tim@bastelfreak.de>
@HelenCampbell
Copy link
Contributor

Merged 👍 Super good job to everyone involved!

@david22swan
Copy link
Member Author

Big thanks to both @bastelfreak, for doing the heavy lifting on getting this work done and @ekohl, for his his excellent reviews.

@david22swan david22swan deleted the ubuntu1804 branch November 30, 2018 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants