Debugging Cookbooks - chef-boneyard/chef-summit-2014 GitHub Wiki
Friday, Metropolitan, 1000
~30-40 community members
- converge, read failure notes
- extract logic into poro (plain old ruby objects) and rspec those
- 'require "pry"; binding.pry'
- byebug/pry
- using chef-shell (shef)
- using "breakpoint" statements pause execution in chef-shell, but not during a normal chef-client run
- kitchen + guard...then "bundle exec guard start" to monitor local changes (will kick off kitchen converges)
- writing serverspec against existing systems to "survey" reality...then develop against those (so moving systems into chef control is less scary)
- mindset: believe you have a problem / using "git bisect" to organize debugging
- chefspec (tdd)
- reading chef code (yay for open source!)
- editing/updating chef code
- an IDE (eclipse/netbeans) debug -- to explore chef (watching compile/converge phase step by step)
- read the docs (if there is one!) or write it (!) (chef docs are open source...PR welcome!)
- strategically placed "puts" and/or Chef::Log
- using "log" resource gives output during converge (not compile, which "puts" will give you)
- Chef::Log happens at compile
- log resource happens at converge
- foodcritic
- rubocop (recipe linting tools)
- syntastic (for vim) (aside: spf13 is an opinionated vim environment setup project)
- finstyle
- online guides to setup chefspec run (+1) -- look at hw-cookbooks (haproxy, etc) as examples -- chefspec has examples directory (how to test scenarios) -- good starting place
- can we use pry-remote? - I think so ... my first stab ;) https://github.com/jmccann/kitchen-binding