When to create a resource VS recipe

Hi,

I'm facing a dilemma from an architectural standpoint. I'm stuck on knowing when to create a resource VS using a recipe.

I know a recipe is just a collection of resources, and that a resource can also utilize other resources. some recipes I create are heavily resource driven and can be quite lengthy (but not difficult to understand)

a recipe I've developed calls on numerous resources to perform a patching procedure at an organization I work for.

I'm trying to determine if I should leave the recipe heavily resource driven or convert the recipe to a resource and give it an action called :patch. and then to create a recipe that simply calls on that resource.

appreciate the advice or suggestions.

1 Like

Chris,

The real reason you'd want to convert a recipe over to a resource is if you want to use that code more than once in a run_list and you want to pass in different tuneable values each time. In your recipe you have a collection of built-in chef resources and then some attributes so you can tune them. You can't include that recipe more than once though so it's not truly reusable. You set the tunables once per run list and include it once per run list. You can write a resource though that can be used as many times as you want in a run_list and each instance of that resource can use property values.

So if you have a big collection of resources in a recipe and you just use it once maybe there's not a whole lot of value in making that a resource. If you want to hand it off to other users though and allow them to each use it slightly differently via properties, then a resource is probably what you want.

-Tim

4 Likes

@tas50

This was super great answer and answered my question! Thanks a bunch! Well thought out as well. I hope Google or Bing or DuckDuckGo indexes this so others who have the same question can find this.

Thanks again,

Chris