Debugging Cookbooks - chef-boneyard/chef-summit-2014 GitHub Wiki

Location

Friday, Metropolitan, 1000

Convener

Participants

~30-40 community members

Summary of Discussions

  • 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!)

logging output in recipes

  • 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

Linters

  • foodcritic
  • rubocop (recipe linting tools)
  • syntastic (for vim) (aside: spf13 is an opinionated vim environment setup project)
  • finstyle

what we want

  • 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

What will we do now? What needs to happen next?

⚠️ **GitHub.com Fallback** ⚠️