Skip to content

Instantly share code, notes, and snippets.

@phrawzty
Created April 27, 2012 12:33
Show Gist options
  • Save phrawzty/2508852 to your computer and use it in GitHub Desktop.
Save phrawzty/2508852 to your computer and use it in GitHub Desktop.
Ersatz puppet module for dealing with node.js
class nodejs {
$packages = [ 'nodejs', 'nodejs-dev' ]
package { $packages:
ensure => present
}
exec { 'install_npm':
command => '/usr/bin/curl http://npmjs.org/install.sh | sh',
creates => '/usr/bin/npm'
}
}
define nodejs::npm (
$ensure = present
) {
$grepper = "/usr/bin/npm ls | grep '${name}@'"
if ( $ensure == 'absent' ) {
exec { "npm_remove_${name}":
command => "/usr/bin/npm remove ${name}",
onlyif => "${grepper}"
}
}
if ( $ensure == 'update' ) {
exec { "npm_update_${name}":
command => "/usr/bin/npm update ${name}",
onlyif => "${grepper}"
}
}
if ( $ensure == 'present' ) {
exec { "npm_install_${name}":
command => "/usr/bin/npm install ${name}",
unless => "${grepper}"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment