Quick StartΒΆ

[edit on GitHub]

For the quickest way to get started using Chef:

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

  2. Set your system Ruby to this path:

    $ /opt/chefdk/embedded/bin/ruby
    
  3. Generate a cookbook:

    $ chef generate app first_cookbook
    

    where first_cookbook is an arbitrary cookbook name.

  4. Change into the first_cookbook directory.

  5. Update the default.rb recipe in the generated cookbook to contain:

    file "#{ENV['HOME']}/test.txt" do
      content 'This file was created by Chef!'
    end
    
  6. 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!