Skip to content
markbirbeck edited this page Nov 30, 2011 · 3 revisions

Welcome to the vagrant-scripts wiki!

To use these Chef scripts for local development you'll need to install both Chef and Vagrant (details below).

Also, if you are planning to launch servers via Knife then you'll need to set up Opscode (details below). Once done you'll be able to launch a new instance on EC2 with the following command:

knife ec2 server create \
  -i ~/.ssh/your_rsa \
  -I "ami-3693a542" \
  -f m1.small \
  -G default,ui-stack \
  -N es-server01 \
  -r "recipe[apt],recipe[git],role[es-server]" \
  --region eu-west-1 \
  -S your_rsa \
  -x ubuntu \
  -Z eu-west-1a

(See Ubuntu 10.04 LTS (Lucid Lynx) Daily Build for a list of available AMIs.)

Install and configure Chef

Chef is used to create installation scripts. It can be used with both VMs and remote servers.

Installing Chef on a Mac

Chef requires XCode before it can be installed.

Installing XCode

Using the Mac OS X Install DVD that came with your Mac, open the Optional Installs folder and then click on XCode to install (accept the default settings).

On Lion you can simply use the AppStore.

Installing Chef

Link your Chef configuration directory to your Chef directory on Dropbox:

ln -s ~/Dropbox/personal/config/chef ~/.chef

This will allow you to use the same configuration settings on multiple machines.

Now run the following command to install Chef and Knife (you'll be prompted for your password because you are using sudo):

sudo gem install chef net-ssh net-ssh-multi fog highline knife-ec2 knife-github-cookbooks

Install VirtualBox

To install VirtualBox, first download VirtualBox, and then click on the image to mount it. Next, open a terminal window and run the command:

sudo installer -pkg /Volumes/VirtualBox/VirtualBox.mpkg -target /Volumes/Macintosh\ HD

Finally, if you have installed the AddItemToDock utility then you can create a shortcut on the taskbar with:

additemtodock /Applications/VirtualBox.app

Install Vagrant

First, update RubyGems:

sudo gem update --system

Next install Vagrant:

sudo gem install vagrant

If you haven't done so already, read Why Vagrant?

Setting up Chef on Opscode

If you are planning to use Chef to deploy additional servers outside of our normal cloud, then the following steps get you set up with Knife and Opsode.

First, sign up for a free account with Opscode (note that the first five nodes are free):

https://community.opscode.com/users/new

Next set up your keys as outlined in the step labelled You should set up your User and Organization on this page:

https://opscode.tenderapp.com/kb/start/2-setting-up-your-user-environment

The downloaded keys should be placed in the ~/.chef directory that you created in Install and configure Chef:

mv USERNAME.pem ~/.chef
mv ORGANIZATION-validator.pem ~/.chef

You can then verify your set-up by going into the Chef repository and running the client list command:

cd ~/Documents/workspace/chef-repo
knife client list

You should get something like:

[
  "sidewinderlabs-validator"
]

Uploading cookbooks and roles

If you have just created a new organisation then you will need to upload the cookbooks and roles to Opscode:

knife cookbook upload -a
knife role from file roles/es-server.rb