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

Allow for the macports provider to be overridden on macos #321

Merged

Conversation

kizzie
Copy link
Contributor

@kizzie kizzie commented Sep 20, 2017

A vague pondering on how to fix this issue - not sure its 100% working or if my macvm is not happy about npm for other reasons. But any thoughts?

@kizzie
Copy link
Contributor Author

kizzie commented Sep 20, 2017

Hmm, so the next issue with this is that the /root/.npmrc file can't be created for npm as that user doesn't exist for macos

@kizzie
Copy link
Contributor Author

kizzie commented Sep 20, 2017

There we go, working when you pass in

class { 'nodejs' : mac_provider => 'homebrew' }

if nothing else

@kizzie kizzie force-pushed the feature/236-override-macports-provider branch from c2ad17a to c1b4424 Compare September 20, 2017 13:04
Copy link
Member

@juniorsysadmin juniorsysadmin left a comment

Choose a reason for hiding this comment

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

Some tests to cover the change would be super as well, as well as some changes to the README

@@ -24,8 +24,20 @@
$repo_proxy_username = $nodejs::params::repo_proxy_username,
$repo_url_suffix = $nodejs::params::repo_url_suffix,
Array $use_flags = $nodejs::params::use_flags,
$mac_provider = undef,
Copy link
Member

Choose a reason for hiding this comment

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

This isn't the right way to do it. For consistency, the best approach is to create a new variable in params.pp $darwin_package_provider = 'macports' then do $darwin_package_provider = $nodejs::params::darwin_package_provider in init.pp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oooh good point, I was having issues with the provider not overriding when the package statement was in the params as well, but actually that could be moved to init and the default still set in params.

@@ -60,9 +60,15 @@
}
}

if $::osfamily == 'Darwin' {
$path = '/var/root'
Copy link
Member

Choose a reason for hiding this comment

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

Given $path is a banned keyword now I think, consider something like $root_npmrc_path = '/var/root/.npmrc' instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh dear, that's going to cause some fun for me (just starting to move things from puppet 3 to 4 and must have missed this one!)

@kizzie
Copy link
Contributor Author

kizzie commented Sep 25, 2017

I'll need to do some reading up on how to get travis to add tests for osx

I wouldn't bother with this for now.

@juniorsysadmin juniorsysadmin added the enhancement New feature or request label Sep 26, 2017
@juniorsysadmin
Copy link
Member

@kizzie I'm okay with merging minus the travis.yml changes, leaving matching rspec-puppet tests for another Pull Request.

I'll need to do some reading up on how to get travis to add tests for osx

I wouldn't bother with this for now.

@kizzie
Copy link
Contributor Author

kizzie commented Oct 15, 2017

Okey dokey, shall remove the travis bits, as I never did get time to look at it - the rspec ones should at least be easier than trying to force beaker into working forit :)

@@ -60,9 +60,15 @@
}
}

if $::osfamily == 'Darwin' {
Copy link
Member

Choose a reason for hiding this comment

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

please use the new facts hash here:
$facts['os']['family']

) inherits nodejs::params {

if $::osfamily == 'Darwin' {
Copy link
Member

Choose a reason for hiding this comment

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

please use the new facts hash here:
$facts['os']['family']

@@ -24,8 +24,13 @@
$repo_proxy_username = $nodejs::params::repo_proxy_username,
$repo_url_suffix = $nodejs::params::repo_url_suffix,
Array $use_flags = $nodejs::params::use_flags,
$darwin_package_provider = $nodejs::params::darwin_package_provider,
Copy link
Member

Choose a reason for hiding this comment

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

please add a puppet4 datatype for this new parameter

@kizzie
Copy link
Contributor Author

kizzie commented Oct 15, 2017

Do you have a preferred way to squash all the commits? Its starting to look a bit of a mess :) (and I'll have to work out what is up with that test when I'm back at work and have more tools with me than just atom and a command prompt - I think changing it from ::osfamily to the new fact style may have caused some interesting times for the tests that don't define it explicitly?)

@kizzie kizzie force-pushed the feature/236-override-macports-provider branch from 1daba1f to 3b250da Compare October 15, 2017 09:12
@bastelfreak
Copy link
Member

bastelfreak commented Oct 15, 2017

Personally I prefer a history with small commits, so this is in general okay. Can you rebase and get rid of 2c1ca67 and 96e53dc?

0511a52, 0276ab1 and 5911eb3 can be squashed into f290be1

@bastelfreak
Copy link
Member

Can you check the email address used in the first 6 commits? The used email address isn't associated with your github account.

@kizzie
Copy link
Contributor Author

kizzie commented Oct 15, 2017

Oooh work laptop vs home computer. That's awkward. And annoyingly identifiable. Ho hum!

@kizzie kizzie force-pushed the feature/236-override-macports-provider branch 2 times, most recently from e40c4b9 to b853d4a Compare October 16, 2017 13:52
@kizzie
Copy link
Contributor Author

kizzie commented Oct 16, 2017

So my initial guess was correct, the rspec tests don't like $facts['os']['family'] for anything but ubuntu based systems - it's happy with $facts['osfamily'] though - Not sure whether you want me to go through and work out how to change all the tests to work, or whether to use the older style fact hash?

@bastelfreak
Copy link
Member

$facts['os']['family'] is probably not correctly mocked :(. Using the older $facts['osfamily'] is fine as well. It won't disappear soon.

@kizzie kizzie force-pushed the feature/236-override-macports-provider branch from b853d4a to 4e6eb7d Compare October 17, 2017 09:01
@kizzie
Copy link
Contributor Author

kizzie commented Oct 17, 2017

All fixed up - with some added tests and a bit in the read me :)

@juniorsysadmin juniorsysadmin removed needs-docs needs-tests needs-work not ready to merge just yet labels Oct 17, 2017
@kizzie kizzie force-pushed the feature/236-override-macports-provider branch from e9ef5ea to 05cc203 Compare December 18, 2017 07:55
@kizzie
Copy link
Contributor Author

kizzie commented Dec 18, 2017

There we go. Different morning, different realisation that master may have updated. Hopefully all in order now.

@@ -57,6 +57,8 @@
$npm_path = '/usr/bin/npm'
$repo_class = '::nodejs::repo::nodesource'
}

$package_provider = 'apt'
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to set this and others (yum, zypper etc) to undef unless it's non-standard (macports? chocolatey?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it over

@@ -18,7 +18,9 @@
}
}

Package { provider => $nodejs::package_provider }
if $nodejs::package_provider != undef {
Copy link
Member

Choose a reason for hiding this comment

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

Technically this is not needed. When undef it'll fall back on the default value from puppet.

@@ -18,7 +18,7 @@
it 'the file resource root_npmrc should be in the catalog' do
is_expected.to contain_file('root_npmrc').with(
'ensure' => 'file',
'path' => '/root/.npmrc',
'path' => '/.npmrc',
Copy link
Member

Choose a reason for hiding this comment

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

This is unexpected. We should fix a value for that fact. Could you add it to spec/default_facts.yml? I'll submit a PR to modulesync_config to ensure it's not overridden.

it 'the file resource root_npmrc should use /var/root for the path' do
is_expected.to contain_file('root_npmrc').with(
'ensure' => 'file',
'path' => '/.npmrc',
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't match the description. Maybe this should be left out since it's already tested above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could either leave it out or override the fact for this test to be closer to the default that Darwin should come up with?

@kizzie kizzie force-pushed the feature/236-override-macports-provider branch 2 times, most recently from 890c9bb to b485c6f Compare December 22, 2017 12:02
@kizzie
Copy link
Contributor Author

kizzie commented Dec 22, 2017

I have no idea why the build is failing to find bundle, any ideas? (it may be that bundler 1.16.1 was released yesterday and isn't quite making it to the build node?)

.travis.yml Outdated
@@ -7,6 +7,7 @@ before_install:
- bundle -v
- rm Gemfile.lock || true
- gem update --system
- gem pristine bundler
Copy link
Member

Choose a reason for hiding this comment

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

Drop this line - after a rebase to master you should have a green build

@@ -12,3 +12,4 @@ concat_basedir: "/tmp"
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
root_home: /root
Copy link
Member

Choose a reason for hiding this comment

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

Add this to default_module_facts.yaml as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

If it's in default_module_facts.yaml then can't it be removed here? This file is modulesynced while the other isn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I take it out of here then the tests start failing as its not being picked up by from default_module_facts.yaml

Copy link
Member

Choose a reason for hiding this comment

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

Then I'm not that clear of mind yet. Just leave it in and if it's an issue in the modulesync we'll fix it then.

@kizzie kizzie force-pushed the feature/236-override-macports-provider branch from 7a76d31 to b485c6f Compare January 2, 2018 10:08
@kizzie kizzie force-pushed the feature/236-override-macports-provider branch from b485c6f to 0e57b70 Compare January 2, 2018 10:09
@kizzie kizzie force-pushed the feature/236-override-macports-provider branch from 0e57b70 to bd02e1b Compare January 2, 2018 10:14
Copy link
Member

@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.

Looks good, just some minor changes.

@@ -12,3 +12,4 @@ concat_basedir: "/tmp"
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
root_home: /root
Copy link
Member

Choose a reason for hiding this comment

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

If it's in default_module_facts.yaml then can't it be removed here? This file is modulesynced while the other isn't.

file { 'root_npmrc':
ensure => 'file',
path => '/root/.npmrc',
path => "${root_npmrc_path}/.npmrc",
Copy link
Member

Choose a reason for hiding this comment

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

You can use "${facts['root_home']}/.npmrc" to remove the additional variable.

@juniorsysadmin juniorsysadmin merged commit e0b6645 into voxpupuli:master Jan 4, 2018
@juniorsysadmin
Copy link
Member

juniorsysadmin commented Jan 4, 2018

@kizzie Thanks for this PR, I have just squashed commits and merged.

@ekohl
Copy link
Member

ekohl commented Jan 4, 2018

Thanks for addressing all of my many comments @kizzie!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants