Investigating Service Dependency in Chef Cookbooks

I needed to learn how a bunch of chef cookbooks interact, how they depend on each other,  and how the services that they configure depend on each other.

In order to make this task a little easier, I wrote a python script which could extract the dependencies in three ways and output them as a csv-pairs, each row just contains an item and one other item that the first depends on. This is one of the input formats supported by the graph visualisation application Gephi.

Three ways of looking at cookbook dependencies:

  1. Cookbook dependencies on other cookbooks based on those declared in each cookbook’s metadata.json
  2. Role dependencies on other roles and recipes based on each Role’s runlist.
  3. Service usage in recipes – Many of these cookbooks use a common utils cookbook with contains a set of methods of the form get_blah_endpoint(service-name,blah,blah). By looking at which roles end up using which recipes, and which recipes request endpoints for which services, we can work out which roles have actual runtime service dependencies. This option is used to generate the graph below.

rcbops usage deps2

Ps: Incase it offends you that I’m parsing ruby code with python:

tumblr_l6ouy08TEp1qz9muno1_r1_400