Use library-recipe 2 times on 1 node

Hi,

i have the following problem:

i have one git repo with a common recipe called DeployService. This contains multiple steps to deploy a selfcoded service on a windows machine. We have a lot of such services.

Now i create in another git repo an “application cookbook” or “wrapper cookbook”. This reference the Deployservice cookbook.

In the app cookbook i build 2 recipes. Both of them calls them with “include_recipe DeployService” and set with node.override attributes for this specific service. Like this:

service1_recipe:
- set attributes for service 1
- include_recipe DeployService

service2_recipe:
- set attributes for service 2
- include_recipe DeployService

I try to apply both of them to the same node with kitchen. But it seems that kitchen runs the deployservice recipe only one time.

I cannot find the problem. Can you help me? Thanks

regards
Christian

Hi Christian,

If I understand correctly you want to use the same recipe twice in a Chef run but with different attribute values setting the resources contained in that recipe?

Unfortunately this is not possible and is documented here https://docs.chef.io/recipes.html (go to “Include Recipes”).

Your best options are to turn your code into a definition or custom resource.

Good luck.