###Preface
The BlueBoxes are bare. Like, seriously silicon desert wasteland bare. You will probably need to install some very basic standard packages like curl, wget, make, etc. before you are even able to start using remote scripts to bootstrap your system. apt-get is your friend and will get you through these trying times. Don't forget to sudo.
###0a -- For Empty VPSes Bootstrap your system by installing Ruby 1.9.3 and installing Chef
Per the point above, when you first come to your bare VPS there will probably not be a ruby version or a chef version installed. Fortunately the wizened nerds in the DevOps community have put together various scripts for "bootstrapping" this process. This one seemed to be a winner for the Ubuntu version running on our BlueBox VPSes (12.04): https://gist.github.com/2370476
--> This part will take several minutes. Take a pomodoro. Down a quad espresso. GET AMPED FOR DEVOPS. After it is done, you should be able to run which ruby and which chef-solo and see some results. If you don't see anything, then something is awry.
###1. Set up a Chef Directory
For working on Vagrant, it makes this to be in the same directory where your Vagrantfile lives; this way you will access it at /vagrant/chef when you are ssh'ed into your vagrant.
###2. Create a solo.rb and node.json in the top level of your chef directory
solo.rb is the basic "run file" for your chef-solo, and node.json stores some attributes like the list of recipes to run.
For now, add these to solo.rb:
cookbook_path File.expand_path("../cookbooks", __FILE__)
json_attribs File.expand_path("../node.json", __FILE__)
###3. create a "main" cookbook to install some basic packages for starters Directory structure should look like this
-- chef
| -- solo.rb
| -- node.json
| -- cookbooks
| -- main
| -- recipes
| -- default.rb
###4. Put some basic stuff in your recipe
In default.rb add the line package "git-core"
In node.json add { "run_list": ["recipe[main]"] }
This will tell your recipe to use the system's package manager to install git-core, and adding it to your run_list will tell chef to run this recipe.
###5. Install some cookbooks using Knife, Chef's built-in cli Knife is sort of like rubygems for pulling chef cookbooks from the web. By default it pulls the hosted repos from Opscode's community site, but with the knife-github-cookbooks plugin you can also pull from any git repository.
To get knife-github-cookbooks run: gem install knife-github-cookbooks
####5a. To use knife, you have to init a git repo in your chef directory. This is opscode's way of encouraging you to treat your chef repos as source code, which is probably a good idea. Once you have a lot of stuff in here you will want to have it backed up, and getting it on github will make it easier to share with your team.
####5b. Let's try using knife to install a cookbook -- this may get hairy
From your chef directory (hopefully in the same directory as your Vagrantfile, if you're following along in vagrant mode), try running:
knife cookbook site install nginx --cookbook-path ./cookbooks
With any luck, you'll get the nginx recipe copied down and can add it to your runlist in node.json It will look like this: { "run_list": ["recipe[main]", "recipe[nginx]" }