Vagrant: hello box, thank you for coming

Vagrant logo

Vagrant is a virtual machines management tool that allows us to easily create, run, configure and share customized virtual systems. The main goal of Vagrant is to provide a centralized way to share preconfigured virtual machines for software developers. In development teams, all members must share not only and up-to-date project source, but also the same system configuration: database management systems, web servers, application servers, IDEs, development kits,... It is almost impossible to keep them identical in each station, not to mention the same specific versions of each program needed. Another issue that comes to mind if you have ever suffered this is when your system crashed or you simply upgrade your hardware, or some IDE requires the latest operative system from Redmond: you will start again from scratch installing all the components you need to have your environment ready to work. This is a sort of myth of sisyphus adapted to coders.

Virtualization comes to the rescue! but this is not just about sharing a common virtual machine among developers. Vagrant wraps the virtualization system, and so we are not necessarily tied to any of them. Vagrant supports Virtual Box (easily available), VMWare and even Amazon EC2, is easy to get into it.

Up and running

In two easy steps we init a vagrant machine (a default 64bit box) and then we just boot it with vagrant up. The first time the box must be downloaded

d:\vm\vagrant init hashicorp/precise32
...
d:\vm\vagrant up

The first command will create a Vagrant configuration file, nice and self-documented. This is how it looks like in a windows host:

Vagrant running
Automated configuration

Ok, we get a basic machine but what happens with the configuration. Vagrant can take advantadge of powerful configuration tools suchs as chef and puppet. These two deserve not a post but one book each. In a nutshell, this kind of software automates machine configuration; for programming environments there are already tools that using declarative description you get code. In the same way, sysadmins now are able to deploy several servers perfectly configured in no time, just writing configuration (and shareable) files. That easy.

Going social

Even developers communicate and share (code), but mainly between them, though. And so for development boxes. Officialy available we have the Vagrant Cloud, were we can grab popular boxes with some rating information included. It's very easy to join the cloud and create your own boxes. You'll just face one little problem, you must upload your box somewhere. Other reference site could be Vagrant Box, with many different linux flavors for you to pick. There are, also, other propietary boxes available.

Educational purposes

Maybe in a software development company or department you just the same kind of environment all the time. But Vagrant could be a really great tool to use at school. Depending on the subjects students have to switch their environments and they will drive you crazy because two of them don't have the latest JVM or the usual suspects don't know even how to switch off their windows8. You could prepare one Vagrant box, perfectly configured for each subject, even for each specific unit of the same subject. For example, preparing an Android development environment it's really a pain in the ass. Instead of stuffing one single machine with all the software you need, a good use of Vagrant could avoid conflicts and guarantee that all students are using exactly the same environment. As easy as pie.

It is not unusual that you try to learn something new and that leads you to learn many other things. Here I have written a bunch of names to be aware of, and I hope that this post helps as a reminder for the near future. Greetz 4 u.

by Pello Altadill 08/13/2014 00:35:34 - 924 hits

Persistent session control in Node.js with express 4

In this series of posts I'm trying to show, in the simplest way possible, how to develop a web application in Node.js adding all the features that in other environments we take for granted: database access, form validation, i18n, and of course session management. Express is the framework of choice for this purpose, the problem is that maybe many information you find out there may be deprecated or useless since express 4 was released. Here I'm trying to use the latest (express4) and the coolest, but in an...

by Pello Altadill 08/03/2014 00:08:50 - 1888 hits

More »

Node.js internationalization and form validation

In any application, no matter the languages or the environment you are using, it is always necessary to ensure that all data is validated before we try any operation. It's tedious, boring and maybe you prefer to focus on more interesting things but you may fear not only hackers, but also the users who from time to time become true hackers without been really aware of it: just applying unexpected input. For instance a form field could ask for the zip code and a regular user could answer (sincerely) 'I don...

by Pello Altadill 08/01/2014 00:27:41 - 3085 hits

More »

Keeping Node.js app.js clean + custom middleware for express

This post has two purposes: to continue the previous one showing ways to improve the organization of routes and secondly to see how to add your own middleware to an express application. The previous version have a problem when it comes to the routes. We require all of them with a single requ...

by Pello Altadill 07/26/2014 23:03:41 - 1692 hits

More »

Node.js + express routes + mongoose, simple and separated

There are plenty of examples out there explaining how to develop a webserver in node.js using the express framework. There are also great books like Professional Node.js and Smashing Node.js introducing details about express among many other topics. But there is also, imho, a big problem: all of them show different ways to solve the same problem. In addition to that there were changes in the framework (Express has recently changed to version 4) and some documentation and samples could be deprecated, so if y...

by Pello Altadill 07/23/2014 23:45:40 - 2102 hits

More »

Setting different config files in Node.js

External config files When it comes to configuration options it is always desirable to avoid hardcoding config values in our code. Even more, if we are using different config values in development and production environments it is necessary an easy way to switch from one to another. This also becomes useful when your code is public but you want to hide some config files. In Node.j...

by Pello Altadill 07/22/2014 00:52:26 - 1240 hits

More »

Enabling basic authentication for MongoDB databases

MongoDB is extremely easy to install and run. If you are not able to make it work maybe you could feel more confortable using Access or even excel. Well, sorry for that. This short article is but a quick and dirty guide to enable basic authentication in mongodb, and how to create one database with its own user (not a superadmin) with just read/write permissions. If you run mongo...

by Pello Altadill 07/20/2014 00:37:15 - 1567 hits

More »

Python language basics

Python in 21 minutes (or so) For a developer is not enough to know one programming language, it is often said that is good to know many of them. After all the language is but a mere tool to build programs. Python has been around for many years and one of my pending task was to take a look at it. Some friends (@Eugenia4v,@Claw_Shadow,@D00m3dr4v3n) are always tellin...

by Pello Altadill 07/12/2014 23:51:05 - 1388 hits

More »

A night out with Jasmine

A night out with Jasmine Unit testing is much more than a tool for ensuring that a program behaves as expected. Nowadays it's the key for new development techniques such as TDD and BDD in which you begin writing tests before the required code. It's all about requirements and behaviour; developers must focus on understanding the requirements instead of thinking about the way they implement the code. In the event that you've forgotten the fundamental benefits of unit testing here you have a quick...

by Pello Altadill 04/23/2014 00:37:18 - 2809 hits

More »