Skip to content

Instantly share code, notes, and snippets.

@singuerinc
Created August 8, 2013 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save singuerinc/6182601 to your computer and use it in GitHub Desktop.
Save singuerinc/6182601 to your computer and use it in GitHub Desktop.
Vagrant Node + Ruby
Exec {
path => ['/usr/sbin', '/usr/bin', '/sbin', '/bin']
}
# --- Preinstall Stage ---------------------------------------------------------
stage { 'preinstall':
before => Stage['main']
}
class apt_get_update {
exec { 'apt-get -y update':
unless => "test -e /usr/bin/nodejs"
}
}
class { 'apt_get_update':
stage => preinstall
}
# --- Packages -----------------------------------------------------------------
package { 'curl':
ensure => installed
}
package { 'build-essential':
ensure => installed
}
package { 'git-core':
ensure => installed
}
package { 'vim':
ensure => installed
}
package { 'ruby-bundler':
ensure => installed
}
package { 'rubygems':
ensure => installed
}
package { 'nodejs':
ensure => installed
}
# --- Install Ruby ---------------------------------------------------------
class install_ruby {
exec { 'clone_rbenv':
command => "git clone https://github.com/sstephenson/rbenv.git ~/.rbenv",
unless => "test -e ~/.rbenv/bin/rbenv"
}
exec { 'export_path':
command => "echo 'export PATH=\"$HOME/.rbenv/bin:$PATH\"' >> ~/.profile",
unless => "test -e ~/.rbenv/bin/rbenv",
require => Exec['clone_rbenv'],
}
exec { 'add_rbenv_init':
command => "echo 'eval \"$(rbenv init -)\"' >> ~/.profile",
unless => "test -e ~/.rbenv/bin/rbenv",
require => Exec['export_path'],
}
exec { 'restart_sheel':
command => "exec $SHELL -l",
unless => "test -e ~/.rbenv/bin/rbenv",
require => Exec['add_rbenv_init'],
}
exec { 'install_ruby_builds':
command => "git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build",
unless => "test -e ~/.rbenv/plugins/ruby-build/bin/ruby-build",
require => Exec['restart_sheel'],
}
exec { 'install_ruby':
command => "rbenv install 2.0.0-p247",
unless => "test -e ~/.rbenv/bin/rbenv",
require => Exec['install_ruby_builds'],
}
exec { 'set_ruby_version':
command => "rbenv global 2.0.0-p247",
unless => "test -e ~/.rbenv/bin/rbenv",
require => Exec['install_ruby'],
}
}
class { 'install_ruby': }
# --- Install nodejs ---------------------------------------------------------
class install_nodejs {
exec { 'install_python_soft_properties':
command => "sudo bash -c 'apt-get -y install python-software-properties python g++ make'",
unless => "test -e /usr/bin/nodejs"
}
exec { 'add_nodejs_alt_repo':
command => "sudo add-apt-repository ppa:chris-lea/node.js",
require => Exec['install_python_soft_properties'],
unless => "test -e /usr/bin/nodejs"
}
exec { 'apt_get_update2':
command => "sudo apt-get -y update",
require => Exec['add_nodejs_alt_repo'],
unless => "test -e /usr/bin/nodejs"
}
exec { 'install_nodejs':
command => "sudo apt-get -y install nodejs",
require => Exec['apt_get_update2'],
unless => "test -e /usr/bin/nodejs"
}
exec { 'install_nodemon':
command => "sudo npm install -g nodemon",
require => Exec['install_nodejs'],
unless => "test -e /usr/bin/nodemon"
}
}
class { 'install_nodejs': }
Vagrant.configure("2") do |config|
config.vm.box = 'precise32'
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
config.vm.network :private_network, ip: "10.11.12.13"
config.vm.synced_folder "./", "/vagrant", :nfs => true
config.vm.provision :puppet do |puppet|
puppet.manifests_path = 'manifests'
puppet.manifest_file = 'base.pp'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment