Skip to content

Instantly share code, notes, and snippets.

@dsbraz
Created December 4, 2013 20:46
Show Gist options
  • Save dsbraz/7795214 to your computer and use it in GitHub Desktop.
Save dsbraz/7795214 to your computer and use it in GitHub Desktop.
Vagrant com provisionamento via Ruby code
#!/opt/vagrant_ruby/bin/ruby
module Shell
def apt_get(cmd, param="")
sys_call "apt-get #{cmd.to_s} #{param}"
end
def curl(url)
sys_call "curl #{url}"
end
private
def sys_call(cmd)
system cmd
end
end
class Packages
include Shell
def initialize(packages)
@packages
end
def install
puts "installing packages"
apt_get :update
apt_get :install, @packages
puts "installing packages.. done"
end
end
class RVM
include Shell
def install
puts "installing rvm"
curl "-L https://get.rvm.io | bash -s stable --auto-dotfiles --ruby"
puts "installing rvm.. done"
end
end
Packages.new("build-essential git vim nmap").install
RVM.new.install
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", path: "provision.rb"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment