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:
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/ http://docs.chef.io/ run `help' for help, `exit' or ^D to quit. Ohai2u mma@laptop! chef (12.14.89)>
Switch to the attributes mode in
chef-shell
:chef (12.14.89)> attributes_mode
Set an attribute value to be used inside the recipe later...