Using chef-shell

While writing cookbooks, being able to try out parts of a recipe interactively and using breakpoints helps you to understand how your recipes work.

Chef comes with chef-shell, which is essentially an interactive Ruby session with Chef. In chef-shell, you can create attributes, write recipes, and initialize Chef runs, among other things. Chef-shell allows you to evaluate parts of your recipes on-the-fly before uploading them to your Chef server.

How to do it…

Running chef-shell is straightforward:

  1. Start chef-shell in standalone mode:
    mma@laptop:~/chef-repo $ chef-shell
    loading configuration: none (standalone chef-shell session)
    Session type: standalone
    Loading......done.
    
    This is the chef-shell.
     Chef Version: 12.14.89
     http://www.chef.io/ ...

Get Chef Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.