Tag Archives: vagrant

Create a Vagrant image file and share on VagrantCloud

Here we will cover how to create a Vagrant Box. In this case I want to install chef-solo over an Ubuntu/trusty image. You can clone all work in this post from this repo https://github.com/jlebrijo/trusty64-chef.

mkdir trusty64-chef
cd trusty64-chef/
rbenv local 2.1.2
gem install bundle

Create Gemfile:

source 'https://rubygems.org'
gem 'vagrant', github: 'mitchellh/vagrant', tag: 'v1.6.4'
gem 'knife-solo'

Install gems:

bundle
bundle install --binstubs .bundle/bin

Create Vagrantfile: ‘vagrant init’. In order to take access to the image, add to Vagrantfile:

config.vm.network :public_network, bridge: "wlan0", ip: "192.168.10.25"

Start box: ‘vagrant up’. Install Chef in the image:

knife solo prepare vagrant@192.168.10.25 ## password: vagrant

Update Ubuntu:

vagrant ssh
sudo apt-get update

Package the Box: `vagrant package –base trusty64-chef_default_1409751631640_92694 –output trusty64-chef.box`

Add to local Box list: `vagrant box add lebrijo/trusty64-chef package.box`

Upload the box to a HTTP server: `scp trusty64-chef.box lebrijoc@files.lebrijo.com:www/lebrijo.com/files`

Create an account and entry in vagrantcloud.com [lebrijo/trusty64-chef](https://vagrantcloud.com/lebrijo/trusty64-chef)

Chef basics for Rails Developers

In our new collaboration with Tealeaf Academy friends, we are writing about Chef/Vagrant and how to use them to manage and test your servers configuration.

This is a step-by-step guide (including github projects) to bootstrap and cook a basic Rails server:

  • Step 1. Vagrant: Creating your Development environment (Server Virtualization)
  • Step 2. Knife-solo: Kitchen structure
  • Step 3. Librarian: Managing dependencies
  • Step 4. Creating your own cookbook (rails-stack)
  • Step 5. Cook your Vagrant Box
  • Step 6. Cook a real server
  • Step 7. Deploy with Capistrano
  • Conclusions

Enjoy!!

Docker vs Vagrant

Thanks to a question of my friend Xavier: “Is this something that might potentially interest us? CoreOS Now Available On DigitalOcean!“, I reopened this internal discussion “Vagrant or Docker, this is the question?”. Well here are my thoughts ….

CoreOS is a minimal Linux Distro in order to save RAM when you manage Clusters (or slices within a machine). They promise  to use only 144MB RAM.

When you use Docker, you need a host OS in your Server (CoreOS promises to be the lighter host OS).

So the question here is …… should we use Docker?

  • SERVER SIDE:
    • Docker/CoreOS are scalability tools: as Adrian said this is a really powerful tool to scale applications, you can deploy packaged containers (slices) within a server and among servers in a farm. CoreOS seems to help a lot at this point also, running ‘etcd‘ by default.
    • Removes Lock-in: You can move your apps among providers (DO, Rackspace, AWS, Linode,… your private farm). Once you have your container configured, you just need to have a linux host (an AWS linux AMI, Ubuntu, CoreOS ….) with Docker installed.
  • DEVELOPER SIDE: Docker instead of Vagrant to emulate the system locally (take a look at this great discussion between both creators)
    • This is only possible, for the moment, if your app servers are linux (this does not mean that your Dev workstation should be Linux)
    • Docker engine (Virtualization layer) is based on LXC, which manages chroot, network, mount… all kernel “Containerizing” capabilities directly. This efficiency is extreme if your local OS is Linux.
      • Vagrant lies over VirtualBox which creates a lot of CPU and Memo overhead.
    • Portability: Docker allows to reproduce EXACTLY the production scenario in your workstation (or other environments like staging or testing). You just need Docker/Linux installed in both, and Docker acts as an abstraction layer.
      • Vagrant offers images which haven’t the same configuration as your provider’s images (I experienced this directly: ubuntu-14.04 has not the same configuration in vagrantcloud.com‘s box, and DigitalOcean.com’s image)
    • Images weight: Vagrant boxes are much larger than Docker repos (ubuntu/trusty is ~600MB image box, against 64MB as Docker repo)

I was until this weekend with an eye on this Infrastructure Maintenance Stack:

  • Chef: Manages server installation and future configurations.
  • Vagrant: reproduces (approximately) our production server in order to check configurations.
  • Capistrano: Manages continuous deployment.

But due to read (and tests) about Docker this weekend, I am thinking to substitute Vagrant per Docker (the reasons above are really persuasive).

So, hey guys!! what do you think? Is Docker/CoreOs something that might potentially interest us?