How to do it…
Let's find out how knife can help you to look into a cookbook stored in your Chef server:
- 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
- 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...
- Now, you can even show the contents of the
iptables_rule.rb
definition file, as stored on the server:mma@laptop:~/chef-repo $ knife cookbook show iptables 0.14.1 definitions iptables_rule.rb # # Cookbook Name:: iptables # Definition:: iptables_rule # # define :iptables_rule, :enable => true, :source => nil, :variables => {}, :cookbook => nil do ...TRUNCATED OUTPUT... end