Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chef node - check if recipe will run on it, looking inside roles as well

I want to find out if a specific recipe will be run on a node from inside a different recipe. I can node.recipe?(recipe_name) method, however some of my recipies are managed by roles and recipe? does not seem to look into the roles run list.

Is there an easy way to find out if my recipie[redis] is going to be run on the current node?

like image 487
henry.oswald Avatar asked Jun 26 '13 21:06

henry.oswald


1 Answers

You're looking for the recipes method. Note the trailing s! So:

node.recipes.include?(recipe_name)

Also note that there is a similar pair of methods for role inspection. Those are role and roles. For both roles and recipes, the singular form is for those directly assigned and the plural for the fully resolved set.

like image 156
Dave S. Avatar answered Sep 30 '22 08:09

Dave S.