sous-chefs / java

Development repository for the java cookbook
https://supermarket.chef.io/cookbooks/java
Apache License 2.0
386 stars 637 forks source link

Cannot 'Include' in Run List #626

Closed ndunn990 closed 4 years ago

ndunn990 commented 4 years ago

:ghost: Brief Description

Cannot 'include' this in order to leverage the custom resources. This is likely not a bug, but my failure to understand.

:pancakes: Cookbook version

8.3.0

:woman_cook: Chef-Infra Version

Chef-Infra Server: 12.18.14 Chef-Client: 15.11.18

:tophat: Platform details

UBUNTU 16.04.6 LTS (Xenial Xerus)

Steps To Reproduce

Steps to reproduce the behavior:

NOTE: we use policyfiles.

First Attempt

  1. Add depends 'java', '~> 8.3.0' to metadata.rb in wrapper cookbook.
  2. Add a few lines to default recipe in our wrapper cookbook to use one of the custom resources.
  3. Update policyfile and push to Chef Infra server.
  4. Run policyfile.
  5. Receive an error.

Second Attempt

  1. Add the cookbook to the runlist in the Policyfile, instead.
  2. Update policyfile and push to Chef Infra server.
  3. Run policyfile.
  4. Receive an error.

The error in both cases:

RuntimeError Recipe used instead of custom resource

:police_car: Expected behavior

I expected Chef-Client to converge successfully.

:heavy_plus_sign: Additional context

We've been using the java cookbook for some time now. Originally, our wrapper cookbook just allowed the recipes baked in the java cookbook to do most of the work for us. Now that it's been updated to instead provide custom resources, I added the necessary resources to appropriate recipe in our wrapper cookbook. I assumed that the best way to do this was to still 'include' the java cookbook in the run list, but I seem unable to do that since it automatically runs the default recipe and raises the custom-made fatal error.

It's perfectly possible that I'm misunderstanding how I should move forward here. Is there a better way to leverage the custom resources provided by this cookbook? The only other solution I know of would be to download a release...but that just struck me as a bit inelegant.

Or is the default recipe not supposed to raise an error?

damacus commented 4 years ago

Hi @ndunn990!

thanks for taking the time to open an issue. The default recipe is definitely supposed to raise the following error.

Default install recipe is now deprecated
Use one of the documented install resources
See the documentation folder for a list of resources

In broader terms, you should either be looking in the resources documentation folder, or the test cookbook.

The documentation will help with deciding how to use most if not all of the resources. The test cookbook has a number of commonly used examples which we use to test against.

Hope that helps!

ndunn990 commented 4 years ago

Thank you for getting back to me.

I guess my issue boils down to a question regarding best practice. When I create custom resources for myself that need to be utilized in other cookbooks, I typically have the custom resources tucked away in a cookbook whose default recipe does nothing. So, in other cookbooks, I can just 'include' the cookbook that includes the custom resources and utilize them as necessary.

I can just clone this repository and move the custom resources I need into my cookbook, but I just wasn't sure if that was the best practice or if there was a more elegant way.

Or maybe I'm not making a great deal of sense. Unless there's a 'best practice' other than simply cloning the repository and copying the custom resources into my cookbook, you can close this.

damacus commented 4 years ago

Hi @ndunn990,

you might want to reach out to Chef Support or https://learn.chef.io/ for these questions. As they'll be better posed to answer these questions.

You can always drop by the Chef Community Slack where the #general channel is usually super helpful!

Closing down as this is slightly off topic of this cookbook. As the question is really "how do I use custom resources correctly?"