How to clone from a github repo and then run npm install on puppet

Fergie picture Fergie · Aug 20, 2013 · Viewed 10.5k times · Source

I have worked out how to fire up a vagrant box and apt-get install packages

I now want to git clone a node.js repo from github before running npm install and running the app with node app.js

I expected to be able to achieve this by issuing BASH commands, but I see now that puppet requires this to be done in a puppety way. The results from Google on this issue are confusing and inconsistent.

So- how do you tell Puppet to git clone a node.js package from github and then install it with npm install?

Answer

Andrew Dwyer picture Andrew Dwyer · Aug 20, 2013

You can use the puppet-nodejs module to manage npm packages. Take a look at https://forge.puppetlabs.com/puppetlabs/nodejs

Otherwise, this article should explain how to clone a git repo. http://livecipher.blogspot.com.au/2013/01/deploy-code-from-git-using-puppet.html

More info can be found at https://github.com/puppetlabs/puppetlabs-vcsrepo.

Once installed you should be able to do something like:

vcsrepo { "/path/to/repo":
  ensure => present,
  provider => git,
  source => 'git://example.com/repo.git',
  revision => 'master'
}