Chef

Table Of Contents

Install the Chef DK

To install the Chef development kit:

  1. Visit this page: http://www.getchef.com/downloads/chef-dk/ and pick your platform. The Chef development kit supports Mac OS X, Red Hat Enterprise Linux, Ubuntu, and Microsoft Windows.

  2. Select a platform, and then a package. (chef-docs uses the Mac OS X setup within the documentation.)

  3. Click the download button.

  4. Follow the steps in the installer and install the Chef development kit to your machine. The Chef development kit is installed to /opt/chefdk/ on UNIX and Linux systems.

  5. When finished, open a command window and enter the following:

    $ chef verify
    

    This will verify the main components of the Chef development kit: the chef-client, the Chef development kit library, and the tools that are built into the Chef development kit. The output should be similar to:

    Running verification for component '...'
    ..........
    ---------------------------------------------
    Verification of component '...' succeeded.
    
  6. Set the default shell. On Microsoft Windows it is strongly recommended to use Windows PowerShell and cmd.exe.

Set the System Ruby

For many users of Chef, the Chef development kit version of Ruby that is included in the Chef development kit should be configured as the default version of Ruby.

  1. Open a command window and enter the following:

    $ which ruby
    

    which will return something like /usr/bin/ruby.

  2. To use the Chef development kit version of Ruby as the default Ruby, edit the $PATH and GEM environment variables to include paths to the Chef development kit. For example, on a machine that runs Bash, run:

    echo 'eval "$(chef shell-init bash)"' >> ~/.bash_profile
    

    where bash and ~/.bash_profile represents the name of the shell.

    If zsh is your preferred shell then run the following:

    echo 'eval "$(chef shell-init zsh)"' >> ~/.zshrc
    
  3. Run which ruby again. It should return /opt/chefdk/embedded/bin/ruby.

Note

Using the Chef development kit-provided Ruby as your system Ruby is optional. This just depends on how you are using Ruby on your system. For many users, Ruby is primarily used for authoring Chef cookbooks and recipes. If that’s true for you, then using the Chef development kit-provided Ruby as your system Ruby is recommended. But for other users who are already using tools like rbenv to manage Ruby versions, then that’s OK too.

Uninstall the Chef DK

The Chef development kit can be uninstalled using the following steps.

Debian

Use the following command to remove the Chef development kit on Debian-based platforms:

$ dpkg -P chefdk

Mac OS X

Use the following commands to remove the Chef development kit on Mac OS X.

To remove installed files:

$ sudo rm -rf /opt/chefdk

To remove the system installation entry:

$ sudo pkgutil --forget com.getchef.pkg.chefdk

To remove the symlinks under /usr/bin:

$ ls -la /usr/bin | egrep '/opt/chefdk' | awk '{ print $9 }' | sudo xargs -I % rm -f /usr/bin/%

Red Hat Enterprise Linux

Use the following commands to remove the Chef development kit on Red Hat Enterprise Linux-based platforms:

$ rpm -qa *chefdk*

or:

$ yum remove <package>

Microsoft Windows

Use Add / Remove Programs to remove the Chef development kit on the Microsoft Windows platform.