No such cookbook exception in Chef even if cookbook is available and dependency is set - AWS OpsWorks

444 Views Asked by At

I am a beginner in Chef and AWS OpsWorks. I was trying to experiment with custom recipes. I created a git repository having a directory test_cookbook, and configured chef to get cookbooks from it. Inside that, I created files like below;

test_cookbook
  |_metadata.rb
  |_recipes
    |_testrecipe.rb

below is the content of metadata.rb

depends 'magic_shell'

magic_shell is an open cookbook and is available in chef supermarket https://supermarket.chef.io/cookbooks/magic_shell

While I try to execute the testrecipe, I am getting below error;

[2021-01-12T09:52:23+00:00] INFO: HTTP Request Returned 412 Precondition Failed: No such cookbook: magic_shell
 
================================================================================
Error Resolving Cookbooks for Run List:
================================================================================
 
 
Missing Cookbooks:
------------------
No such cookbook: magic_shell

Can somebody tell me why this is happening and how to fix this?

1

There are 1 best solutions below

0
samtoddler On

The dependency is not packaged.

As per the documentation

You can use Berkshelf to package your cookbook dependencies locally, upload the package to Amazon S3, and modify your stack to use the package on Amazon S3 as a cookbook source.

OR pull the dependency using Berksfile and push them to your git source.

For example, I have a dependency for opsworks_helpers in metadata.rb

 $ grep depends metadata.rb
 depends   'opsworks_helpers'

and my current directory structure is like this

    $ tree
    .
    ├── collectd
    ..
    │   │   └── collectd.rb
    │   ├── metadata.rb

    └── opsworks_helpers
        ├── Berksfile
        ├── CHANGELOG.md
        ├── Gemfile
    ...
                    └── serverspec
                        └── spec_helper.rb