The Gluster Blog

Gluster blog stories provide high-level spotlights on our users all over the world

Vagrant : baby steps

Gluster
2012-04-30

Vagrant can build, and destroy, your entire dev setup in a matter of minutes.  Its a powerful tool for achieving a cleanroom enginerring deployment setup.

Vagrant allows you to setup a personalized VM on any machine in a matter of minutes – and reduces the tedium associated with building a local virtualbox environment which mimics a server.  To specify your VM, you can provision (1) an OS version by name and url (vagrant will fetch it for you) and (2) A provisioner – (i.e. this could simply be a shell script which runs after the base box is set up.)  The two commands “vagrant up” and “vagrant destroy” are then all you need to build and tear down your development environment in a matter of seconds.


I’ve given up on alot of things in my life, especially including the idea of managing software on my development machine.   Im not a sysadmin guy but… vagrant is really cool so I’m forcing myself to start using it.  Also DanielKnell told me to… so… Here’s how I got a vagrant VM environment running on ubuntu.

(Vagrant requires a solid Ruby setup – heres what i did to get it working.)
First, install ruby and the ruby bundler :

sudo apt-get install ruby-bundler

To do this , create a directory, cd to it, and create a gem file that looks like this.

source ‘http://rubygems.org’
gem ‘vagrant’, “~> 0.8.1”
gem ‘veewee’, “~> 0.2.0”  
(note that veewee isn’t really necessary here).
THEN 
run the bundle install via the gemfile : 
$> sudo bundle install
Now… In ubuntu 10, I had to update ruby gems to avoid this crazy error related to date formats : 
$>sudo gem install rubygems-update
$>update_rubygems

Now, both veewee and vagrant are installed.

Lets build a VM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

You can borrow a full blown vm base box to start :

vagrant box add base https://s3.amazonaws.com/cloudbiolinux/cbl_ubuntu_11_4_32_20110628.box  

Or, simpler and faster one like this : 

vagrant box add ubuntu-lucid-32 http://files.vagrantup.com/lucid32.box

Next, before I install it – How do I customize it ? 

Vagrant has a set “Vagrantfile” that is initialized for you. This file is created with the “vagrant init my-base-box” command.  For example :

vagrant init ubuntu-lucid-32

So, you first can initialize vagrant via the init command, followed by the box name, and then you can edit the contents of the “Vagrantfile” to point to a shell script which executes some custom instructions, i.e. installing programs.

Now what ?

Now, you can get into your vm :

vagrant ssh

Yipeeee.

Now, as long as you commit changes to the ssh file associated with your Vagrant , anyone can run this vagrant up command, from anywhere, to recreate your environment.

Finally – if you screw up the environment, you can run “vagrant destroy” followed by “vagrant up” to refresh it to the original start point.

——- UPDATES ——–

Just found got this wonderful piece of advice on irc #vagrant :

bgy_Jayunit100: vagrant reload should reboot the box, or you can do it manually by chaining vagrant halt && vagrant up
4:24pmJayunit100aha thanks !

Oh and watch out for this :

Jayunit100reload appears to be provisioning ?
4:28pmadt22is that a problem?
4:28pm….
4:31pmadt22yeah: vagrant reload –no-provision

BLOG

  • 06 Dec 2020
    Looking back at 2020 – with g...

    2020 has not been a year we would have been able to predict. With a worldwide pandemic and lives thrown out of gear, as we head into 2021, we are thankful that our community and project continued to receive new developers, users and make small gains. For that and a...

    Read more
  • 27 Apr 2020
    Update from the team

    It has been a while since we provided an update to the Gluster community. Across the world various nations, states and localities have put together sets of guidelines around shelter-in-place and quarantine. We request our community members to stay safe, to care for their loved ones, to continue to be...

    Read more
  • 03 Feb 2020
    Building a longer term focus for Gl...

    The initial rounds of conversation around the planning of content for release 8 has helped the project identify one key thing – the need to stagger out features and enhancements over multiple releases. Thus, while release 8 is unlikely to be feature heavy as previous releases, it will be the...

    Read more