Skip to content

Allow installation of NPM packages #1

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

iamcarrico
Copy link

Howdy!

I was looking for an ansible way to install node, and since most of them go though the old PPA-- this was the only one that does it the new way.

Anyway--- I made a few minor changes, a couple yml syntax changes (couldn't run it without those changes). And then created a way to install npm packages as well. I don't know of a way to use items only if a variable exists, so instead I made one with a dummy package name. Ansible will then install everything except that package (if the user doesn't override).

Also... it isn't up on Ansible galaxy yet. I am guessing that is because this is ... 7 days old? Either way, can you push it? 👍

Thanks mate!

@wolfeidau
Copy link
Contributor

Hey sorry for the delay in reviewing this, we haven't published this yet as I am waiting for @rvagg to get back from holidays. Plan on testing this more thoroughly once he gets back, hence the stall.

Is there a reason you have used a place holder entry in the array of global modules? Could you just declare an empty array as the default?

Cheers

@iamcarrico
Copy link
Author

Only reason: I didn't know how to off hand and was working on a bunch of other tasks to setup my server. But I will change that quickly.

@thlorenz
Copy link
Contributor

thlorenz commented Sep 4, 2014

Fwiw, installing npm modules doesn't belong in this role IMO.
This role is to install node and that's a clear concern and it should stay that way.

Couldn't we create an npm role or maybe even a module similar to apt to achieve that without muddling the concern of the node role?

@iamcarrico
Copy link
Author

@thlorenz I see the point of having the two separate, but I also think they are linked for many people's deployment. As it is such a simple piece, I don't see the need for separating them out.

@thlorenz
Copy link
Contributor

thlorenz commented Sep 4, 2014

As it is such a simple piece, I don't see the need for separating them out

Everything starts out as a very simple piece, but most grow more complex afterwards. However once it is included with this role it can never be removed without breaking backwards compat.

Therefore I maintain it'd be a better idea to have it separate.
I mean how hard is it to add the line xxxxx.npm to your - roles?

@iamcarrico
Copy link
Author

Good point.

Well, do you want to pull this out and put it into its own repo / ansible-galaxy? I think it would make sense to have it be within the nodesource org, for consistency?

@thlorenz
Copy link
Contributor

thlorenz commented Sep 4, 2014

@iamcarrico nice idea, lets see what the others think about that.

/cc @wolfeidau @chrislea @rvagg @joemccann

@chrislea
Copy link
Contributor

chrislea commented Sep 4, 2014

Well just putting in my $0.02 here... I went through this sort of thing making Debian / Ubuntu packages a ways back. I used to make separate packages for node, node devel (header files and stuff), and npm. I then stopped doing that and started making a single package that had everything at the request of Joyent.

The reasoning was that these days, you're not really using node correctly if you're not using npm, and you can't use npm without the development files. So while I understand that having separate roles is sort of the "pure" thing to do, if we're following the same logic we'd just have a single role that installed everything.

@rvagg
Copy link
Contributor

rvagg commented Sep 5, 2014

What's the use-case here? The only sensible one I can see for an Ansible role is to install global packages as commands, like npm install st -g, tho I'm not sure how common this kind of use is for real deployments.

@iamcarrico
Copy link
Author

Not all ansible scripts are for deployment servers--- I use this for a local vagrant box. I would like to install some global packages for me always to use (e.g. gulp and yeoman)

@rvagg
Copy link
Contributor

rvagg commented Sep 5, 2014

ah yes, gulp, yeoman, grunt, those are all pretty popular globals, ok, +1 from me, we should make a separate role for this

@wolfeidau
Copy link
Contributor

Yep +1 for separate role, and great to see some good discussion on this, I love open source.

We also install node-gyp via Ansible at the moment albeit in our CI role (which is of course way to big).

@iamcarrico
Copy link
Author

👍 Open source. Let me know if I can help y'all on this one.

@rvagg
Copy link
Contributor

rvagg commented Sep 5, 2014

@wolfeidau we're doing that in our docker images: https://github.com/nodesource/docker-node/blob/master/Dockerfile#L16-L17 tho it's mainly so that we prime the images with the stuff downloaded to .node-gyp so you don't have to wait if you run any builds as root.

@wolfeidau
Copy link
Contributor

O that is a damn good idea, mite be worth optionally doing the same thing in this role.

Tricks like that make stuff like this invaluable.

@conorgil
Copy link

conorgil commented Sep 9, 2015

We are currently using this to install packages via npm: http://docs.ansible.com/ansible/npm_module.html. Does this satisfy the use-case discussed in this thread about installing npm packages separately?

@iamcarrico
Copy link
Author

@conorgil this code is just a wrapper around that.

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

Successfully merging this pull request may close these issues.

6 participants