O'Reilly logo

Test-Driven Infrastructure with Chef by Stephen Nelson-Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Chef to Write Infrastructure Code

Now that we have Ruby and Chef installed, and are set up on the platform, we’re able to start using Chef to apply the Infrastructure as Code paradigm. Given that the whole paradigm we are discussing is about managing our infrastructure as code, our first step must be to create a repository for our work. The quickest way to do this is to clone the example Chef repository from Opscode’s GitHub account:

$ git clone http://github.com/opscode/chef-repo.git

This repo contains all the directories you will work with as part of your regular workflow as an infrastructure developer. It also contains a Rakefile that handles some useful tasks, such as creating self-signed SSL certificates. In practice, though, you’re unlikely to use rake, as Knife will do more than 99% of the tasks you’ll find yourself needing to do.

Now, because we cloned this repository from GitHub, it will currently be set to fetch and pull from this example repository. We want to have and use our own repository. The simplest approach is to use GitHub, which provides limitless public repositories and offers bundles of private repositories starting from $7 a month. Alternatively, it’s not difficult to set up and run your own Git server. Although not mandatory, I recommend that you sign up for GitHub (http://github.com) now (if you haven’t already), and follow the simple instructions to create a repository. Call it chef-repo to keep things simple. Once you’ve got a local copy of the Chef ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required