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:
- Cookbook dependencies on other cookbooks based on those declared in each cookbook’s metadata.json
- Role dependencies on other roles and recipes based on each Role’s runlist.
- 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.
Ps: Incase it offends you that I’m parsing ruby code with python: