Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 13 down vote accepted

Something like

exec { "install npm":
    command => "/usr/bin/curl http://npmjs.org/install.sh | sh",
    creates => "/some/directory/somewhere"
}

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.