Quick Start

[edit on GitHub]

For the quickest way to get started using Chef:

  1. Install the Chef development kit: https://downloads.chef.io/chefdk/.

  2. Generate a cookbook:

    $ chef generate cookbook first_cookbook

    where first_cookbook is an arbitrary cookbook name.

  3. Navigate to the first_cookbook directory.

  4. Update the cookbooks/first_cookbook/recipes/default.rb recipe in the generated cookbook to contain:

    file "#{ENV['HOME']}/test.txt" do
      content 'This file was created by Chef!'
  5. Run the chef-client using the default.rb recipe:

    $ chef-client --local-mode --override-runlist first_cookbook

This will create a file named test.txt at the home path on your machine. Open that file and it will say This file was created by Chef!.

  • Delete the file, run the chef-client again, and Chef will put the file back.
  • Change the string in the file, run the chef-client again, and Chef will make the string in the file the same as the string in the recipe.
  • Change the string in the recipe, run the chef-client again, and Chef will update that string to be the same as the one in the recipe.

There’s a lot more that Chef can do, obviously, but that was super easy!

  • See https://learn.chef.io/ for more detailed setup scenarios.
  • Keep reading for more information about setting up a workstation, configuring Kitchen to run virtual environments, setting up a more detailed cookbook, resources, and more.