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)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>