27 Apr 2013
My good British friend Phil Sturgeon posted an awesome writeup
regarding Vagrant and Chef. I've been meaning to do a post
of my own. Over the last few months a side project of mine has got me
involved a lot with Vagrant, Chef and Veewee. But to
find resources on the Internet, especially tutorials, which combine
all that knowledge is definitely a task I would not wish on anyone
So I figured I'd put together a simple little blog post that gets you
started building out your own testing environment. Just a heads up: I
am going to assume you have the Vagrant dependencies installed. I
prefer installing these from the website and not through RubyGems, but
to each his own. The version I am using is 1.1.3. Everything else
should be picked up automatically from the appropriate files.
I am going to walk you through the steps that I used to build the
example application which is available as a Gist. Remember that
you can just run this using the
vagrant up command and it will be
available (in a few minutes) by accessing the 8080 port on your host
machine. You're still going to have to go through the whole
Veewee build of the base boxes. But after you add the base box
that you've built you can just start the application with
The first order of business is to checkout some base box
definitions. I tend to use Opscode bento repository which
contains Veewee definitions that pre-builds your machines with
Chef 11 already ready to rock. This obviously alleviates the need
to spend time on the nitty-gritty and just get down to the business.
$ git clone git://github.com/opscode/bento.git bento
$ cd bento
$ bundle install
Now that you have the bento repository checked out and all of the
dependencies installed using Bundler you can begin by building
your initial base box. I'm a fan of CentOS but most of the
open source cookbooks out there will work flawlessly with
Ubuntu. So let's start with using that.
$ bundle exec veewee vbox build 'ubuntu-12.04-i386' --nogui --force
$ bundle exec veewee vbox export 'ubuntu-12.04-i386'
$ vagrant box add 'ubuntu-12.04-i386' 'ubuntu-12.04-i386.box'
The first command that we executed there will take a little while to
finish. But it performs a headless installation of Ubuntu 12.04
32-bit and will overwrite any existing Vagrant VirtualBox
machine that previously built in this directory. They key off of the
ubuntu-12.04-i386 definition name. After that we export to the
Vagrant recognized format.
Because Veewee is using Vagrant to interact with
VirtualBox we actually have all of the flexibility with our
base box definitions. What does that mean exactly? Vagrant
has several plugins which allow us to use many different
providers for provisioning. For local testing it makes sense to use
VirtualBox but perhaps our integration machines are vanilla Linux
and we want to use KVM. Its very simple with Vagrant to
configure our project to have multiple providers for provisioning.
But once again for flexibility (and making this tutorial easy) let's
stick with the basics. Our project is very simple and we just want to
get a virtual machine ready for testing. This means we just want a
simple Ruby and Rack application since I'm more familiar
We need to modify our Vagrantfile that was created using the
vagrant init command. This is the file where we define the
directives necessary for provisioning your virtual machine. Once
again, we're going to use Ruby and Rack so your mileage
may vary with any other languages or frameworks.
You can clear out all of the default logic, or place this at the top
so that you have that for reference. Here's the basic changes we're
going to do:
- Set our base box name to the one that we exported using
- Forward HTTP traffic from the Rack application so it is
accessible to our host machine.
- Only use the amount of memory that we think we'll need.
- Provision using Chef 11 a Ruby and Rack
Now that we have our Vagrantfile setup we just need to get all of our
cookbook dependencies. I've kept this a little light so that you can
easily work through everything. Using the librarian-chef gem we can
define cookbook dependencies similar to using Bundler for gems.
$ bundle exec librarian-chef install
I have defined the path the Unicorn webserver to point to the current
working directory which has been mounted in the guest virtual machine
as /vagrant. This is defined in the rack_application Chef role. I am
not going to go into the Rack application itself, you can take a look
at the whole project's repository and check it out.
At this point assuming you've added the base box to Vagrant you can
vagrant up and see the application from your localhost
running on port 8080. Once the virtual machine is running you can use
vagrant reload if you are aking modifications to any recipes or
roles. I'm going to post some more in depth articles about writing
custom cookbooks in the near future, but I hope that this was
useful. If you have any additional questions feel free to hit me up on
27 Feb 2013
A few days ago I wrote a post about marrying Ruby and C and
provided an easy to follow example gist. After spending some more
days hacking on C/C++ integration with the Ruby virtual machine I
decided that finding some quality examples was surely a real big
pain. Many of the problems that we are facing are directly related to
objects being accessed from multiple threads at the same time in
the Ruby virtual machine.
While learning I found writing some example code definitely
helps. This new example is a little more complex, but pretty much
covers most of the bases in regards to basic object functionality. I
decided to leave out inheritance in this example as it was getting to
be pretty big. My goal was to be able to sit down and write the
example, plus a blog post, in a single night. If it took me longer
than a few hours its probably too complex of an example.
I am going to continue diving into embedding the virtual machine, and
with that I hope to be able to continue to document examples here and
on my github account. Feel free to drop me some patches if you
find errors in the code. Or leave a few comments.
My previous example takes some time and shows very basic Ruby
virtual machine integration with a C application. This example expands
on this and includes how you might wrap a C structure and integrate it
with normal functionality inside of Ruby. Some examples that you'll
see here include: instance and class variables, instance and class
methods, using the initialize method and yielding to the calling
Be sure to take some time and read the basic example so that
you're sure to understand how it all works. The script can easily be
changed in the main.c file if you want to
puts some information.
23 Feb 2013
For a few weeks now I've spent some time working on embedding the Ruby
virtual machine into an application service for a Celluloid
server spike. Specifically we took the trunk release of Ruby 1.9.3 and
started integrating our service framework utilizing some of our
tried and true libraries inside of our server code. This is a
similar approach that you would take when developing a native
extension - the commonly used mysql2 gem is an example of this -
where an interface API is written to expose functionality into the
We took a similar approach. The beauty of the Ruby language is
that it is very easy to digest, and even easier to interface
with. I've written up a small example gist which I have included
below that illustrates how easily you can embed the virtual machine
into an existing C application with very little effort.
16 Jan 2013
At Bloomberg we've become amazingly efficient at pushing bytes
over the past thirty years. My role at Bloomberg Government has
changed over the past year that I have been down in Washington. At the
beginning of my tenure my job began with writing blazingly fast data
services to deliver legislative information for consumption by the
Ruby on Rails application. I then helped design and implement our
alerting infrastructure giving our clients the ability to define
custom legislative alerts tailored specifically to their search
criteria. The first six months at BGOV was a complete whirlwind
tour of software engineering, including project management, but in
August I was given the oppourtunity to completely change my role once
Nowadays the sexiest problems to solve, for me, revolve around
distributed/parallel computing systems. We had a dire need to cleanup
our development and production infrastructure ranging from solving
disaster planning, continuous integration (rolling deploys) and
developer productivity. Anyone that has worked on a large team
understands the importance of keeping the machine well-oiled, lean and
fit. All of the moving parts need to be in sychronization to
continuously deliver the product to our customers.
So I am now a part of Team Duct Tape at Bloomberg Government,
keeping the lights on and the cogs moving. Software engineering is
about solving problems - big or small - in the most efficient way
possible. Look forward to some more technical posts regarding
datacenter disaster planning, orchestrating master elections with
Zookeeper and zero-downtime production deployment.
15 Jan 2013
At the beginning of each new year, like everyone else, I reflect
on the previous. The analytical part of my brain asks questions:
Did I achieve everything that I set out to? What was my barrier to
success? I don't actually believe in the whole tradition of
resolutions - if I want to change something about my life I try to
live in the moment as much as possible - but it is always great to
have a plan for the future. So I'm going to step through some of the
decisions I made this year, and hopefully map out in my head what I
would like to achieve for 2013.
By and far the largest change had to be
my change of roles at Bloomberg and relocation to Washington D.C.
which was already in the works a year ago. I was getting disinterested
in my role in Equity Derivatives, and I wanted to get back into the
world of web products. I was lucky enough to land a role at
Bloomberg Government and took the option to move out of the
tri-state area to our nation's capital. I would be lying if I said
that this wasn't a carefully planned move. My whole life I lived in
New Jersey, and for a good portion of my adult life I commuted into
New York City. Like many people in my profession I had the itch (and
oppourtunity) to move to the west coast, but I didn't feel the need. I
was quite happy at Bloomberg, but I just needed a new challenge.
The move to Washington turned out to be the best choice I have made: I
met my amazing girlfriend Anna, a third-year law student at American
University; I got an American Pitbull Terrier puppy named Blue,
"Old Man Wrinkles"; went on a road trip to Tennessee this past summer
with Anna; dropped about twenty pounds; and I have found some awesome
places in Maryland to ride the Monster. There's much more to harp on,
but of course there's also some things that have happened that have
not been so great.
The first and foremost is being farther away from my family and
friends - albeit a two hundred and fifty miles - is definitely the
hardest to cope with. Trying to create a new homebase of friends is
definitely something I need to work on harder, and I took that for
granted while up north. This past summer I was diagnosed with sleep
apnea, which has likely afflicted me for several years now, and has
severely impacted my mental state. Aside from always being exhausted,
this illness has affected my mental state, and I have been struggling
with a bout of depression.
So now on to the good stuff. Here are some goals of mine, call it a
bucket list, that I wish to achieve in the upcoming year. I don't
pressure myself into this too much, but once again, its always nice to
be able to come back to something in the next year to see if my life
lead me to where I predicted.
Take more vacation time. Travel overseas to Europe.
I made this goal for the past two years and have not been able to
deliver. This year I am planning on going somewhere for spring
break - likely Cancun - but later in the year I would like to plan a
trip to Europe. For awhile now I've had the ability to go, but never
pushed myself to pull the trigger. I am not big on planning trips
and I much rather prefer to either go somewhere with little more
than a scheduled room. This obviously isn't a good idea on a limited
time and money budget.
Keep eating relatively healthy, but be much more active.
Last year I successfully dropped about twenty pounds which brings my
total to sixty since I've began this change in life. At the
beginning of December I joined a local rock climbing gym, and up until
the past week I have tried to go a steady three times (per week) to go
bouldering. My goal this year is another twenty pounds which would
bring me to 217 but I wouldn't be against putting on some muscle.
Write more words, and play more video games.
I failed horribly last year at writing. That's going to change this
year. I was able to catch up on playing some video games, but there's
still a huge back catalog that I need to sink some serious man hours
Read at least one book per month.
I actually did a fair amount of reading last year, and I only have
about a dozen or so books that I purchased and didn't get around
to. For anyone that knows me they know that I am a whore for
literature. Tell me that you wrote a book and I'll purchase it to read
at somepoint in the future. Possibly years. Seriously.
I haven't put graduate school back on the list because I am still not
sure what is for me. The logical half of me is telling me to go to
school for an MBA, but another part of me really wants to go back
for a software engineering doctorate in distributed systems.
That's it for now.