Checking existence of included recipe


Hi chefs,
We had some discussion on IRC about this a few days ago, thought I might throw my thoughts to the list.

I have two recipes which include the rabbitmq::server recipe (sensu::rabbitmq and logstash::broker [1][2]), and a bunch of nodes which have rabbitmq-server installed by these. I have a new cookbook which needs to check whether the rabbitmq::server recipe was run on the node, ordinarily I could do if node[:recipes].include?("rabbitmq::default") but in this case, rabbitmq::default isn’t in the node’s recipes because it’s installed by the include statement in the sensu/logstash recipes.

jtimberman helpfully pointed out that node.run_state[:seen_recipes] will be populated with all of the recipes as the run progresses, though in order for this to work, I’d have to make sure the cookbook with the dependency is run at the end of the run. Am I missing a really obvious way of doing this dependency check for a recipe that’s included with include_recipe?



Anthony Goddard
Woods Hole Marine Biological Laboratory