Testing your Chef cookbooks
You know how annoying this is: you tweak a cookbook, upload it to your Chef server, start a Chef run on your node and, boom! It fails. What's even more annoying is that it fails not because a black hole absorbed your node and the whole data center that node lives in, but because you missed a mundane comma in the default recipe of the cookbook you just tweaked. Fortunately, there's a very quick and easy way to find such simple glitches before you go all in and try to run your cookbooks on real nodes.
Getting ready
Install the ntp
cookbook by running the following code:
mma@laptop:~/chef-repo $ knife cookbook site install ntp
Installing ntp to /Users/mma/work/chef-repo/cookbooks …TRUNCATED OUTPUT… Cookbook ntp version 1.7.0 successfully installed
How to do it...
Carry out the following steps to test your cookbooks:
Run
knife cookbook test
on a working cookbook, for example, thentp
cookbook:mma@laptop:~/chef-repo $ knife cookbook test ntp
checking ntp Running syntax...