How to do it…

Let's find out how knife can help you to look into a cookbook stored in your Chef server:

  1. First, you want to find out the current version of the cookbook you're interested in. In our case, we're interested in the iptables cookbook:
    mma@laptop:~/work/chef_helpster $ knife cookbook show iptables
    iptables   3.0.0 0.14.1
    
  2. Then, you can look up the definitions of the iptables cookbook, using the version number that you found in the previous step:
    mma@laptop:~/chef-repo $ knife cookbook show iptables 0.14.1 definitions
      checksum:     45c0b77ff10d7177627694827ce47340
      name:         iptables_rule.rb
      path:         definitions/iptables_rule.rb
      specificity:  default
      url:          https://s3-external-1.amazonaws.com:443/opscode-platform...
    
  3. Now, you can even show the contents ...

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.