Created
April 27, 2012 12:33
-
-
Save phrawzty/2508852 to your computer and use it in GitHub Desktop.
Ersatz puppet module for dealing with node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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