Installing Vagrant on Ubuntu 11.04

Vagrant is a awesome tool for controlling virtual machines used in projects. You have a project folder where you, in a plain file, have defined the needed box for the project (using Vagrant and Puppet/Chef). You can then turn on, off and wipe the box as you see fit. This set of commands installes Vagrant on a Ubuntu 11.04 machine and will show you the basics of Vagrant

If you already have installed VirtualBox, you are ready to install Vagrant.

sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby wget
sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/bin/irb
cd ~
tar xvzf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
cd ..
rm -rf rubygems-1.3.7*
sudo gem update --system
sudo gem install vagrant

Make the following «Vagrantfile» to define a plain Ubuntu box: do |config| = "lucid32"
    config.vm.box_url = ""
    #config.vm.boot_mode = :gui
    #config.vm.forward_port "http", 80, 10080
    #config.vm.share_folder "v-data", "/usbdisk", "/media/usbonhost"

    #config.vm.provision :puppet do |puppet|
    #    puppet.manifests_path = "manifests"
    #    puppet.manifest_file = "puppetscript.pp"

Then simple run

vagrant up

Your new box will start up after the image from have been downloaded. I have commented out gui view (default is headless), forwarding of the 80 port to localhost:10080, sharing a folder with the virtual machine and a Puppet script.

SSH into the box

vagrant ssh

Suspend, halt, resume the box

vagrant suspend
vagrant halt
vagrant resume

Destroy/remove a box. Next time you run vagrant up, you will get a clean box according to the Vagrantfile. Nothing on the box itself will be saved when destroying.

vagrant destroy

See also



Dette innlegget ble publisert i Ubuntu / Linux og merket med , , , , , , , , . Bokmerk permalenken.