Created
December 4, 2013 20:46
-
-
Save dsbraz/7795214 to your computer and use it in GitHub Desktop.
Vagrant com provisionamento via Ruby code
This file contains 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
#!/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 |
This file contains 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
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