yet.org

Bootstrap YET infrastructure using Opscode Chef - part 3 - Rackspace

Last time I spoke about YET infrastructure everything was hosted on HP cloud managed by Chef. The thrid chapter will demonstrate how easy moving to another cloud provider could be when you use such a Configuration Management tool.

Installing Knife Rackspace

Rackspace Cloud Servers use a different variant of OpenStack when we compare it to HP Cloud. So there is a specific plugin to deal with their cloud. To install it you just need to type:

gem install knife-rackspace

Configure Authentication

For this plugin to get access to your Rackspace account you need to add the following lines to your knife.rb

knife[:rackspace_api_username] = "Your Rackspace API username"
knife[:rackspace_api_key] = "Your Rackspace API Key"
knife[:rackspace_auth_url] = "https://identity.api.rackspacecloud.com/v2.0"
knife[:rackspace_compute_url] = "https://dfw.servers.api.rackspacecloud.com/v2"

The compute_url line is optional.

Beware if you checkin this file into Git or equivalent not to put your access code there, use Environment variables instead.

You can check it works by using a basic command like:

knife rackspace flavor list

Bootstrap an instance

You can now instanciate a new node in the Rackspace Cloud with:

knife rackspace server create -r 'role[base],role[yet_server]' --flavor 2 --image 9922a7c7-5a42-4a56-bc6a-93f857ae2346 -i /home/<USERNAME>/.ssh/id_rsa.pub --server-name ww1.yet.org --node-name ww1.yet.org

If the command fails it’s maybe because Rackspace have updated their image IDs since I posted this article, you can check it with:

knife rackspace image list

But it could also be due to an outdated Chef Gem like in my case, update it with

gem update chef

RackSpace Dashboard

As you can see below, your server is currently Building, great !!!. One command line and you’ve got a configured server.

Chef Run

As soon as your server finish building, the Chef Bootstrap will be initiated thru an SSH connection to the node.

Troubleshooting

If you were unlucky you can start over. First delete your instance.

knife rackspace server list
knife rackspace server delete <InstanceID>

Check and delete Chef node and client if it got created

knife node list
knife node delete <node_name>
knife client list
knife client delete <client_name>

Double check your Knife Rackspace command line, your environment, cross your fingers and start over.

To finish my provisionning I just have to use my Rake task to publish my blog:

rake deploy

I hope it worked for you.

Thanks for reading.

Have fun with Chef.