How do I run a shell script from puppet?
Solution 1:
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.
Solution 2:
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.