I need to install npm
which is done by curl http://npmjs.org/install.sh | sh
and being new to using puppet
, I am a bit confused on how this should be done.
I am well aware of creating a package {}
entry that invokes an exec
target, but as I install npm
from source, this isn't going to cut it.
I clearly don't want to build npm
every time my puppet
makes a pull, so I need someway to check if it is installed or not as well, so just making an exec {}
alone isn't enough either.
What can I do?
Something like
Should do the trick.
However, I would strongly advise against doing this, as it makes your installation process dependent on so many other things working correctly, and drops untracked files who-knows-where in your filesystem (and that's even before we start talking about the security implications of running untrusted and unverifiable code automatically). You'd be far better off making a native package for your OS, placing it in a local repo, and installing that using a package resource.
I would "second" everything Womble said about packaging it and installing it via package management tools from a local repository. Depending on the platform, there might also be dependable third-party repositories that you could use.
One minor nitpick regarding Womble's answer: the puppet style guide recommends using single quotes unless you need double quotes for variable interpolation. In the code that Womble shows, there are no variables, so all the " should instead be '.
Note that a lot of the puppet documentation hasn't been updated to reflect this recommendation, so you'll see double quotes in plenty of places even in the official docs. The style guide and puppet-lint both reflect current recommended best-practices, and the docs will hopefully eventually be fixed.