srajappa
srajappa

Reputation: 481

How to override dependency version, when writing wrapper cookbooks, in chef

eg.

I am writing a wrapper cookbook (my_cookbook) for the same purpose I am using the community cookbook (community_cookbook). I face an issue regarding the dependency list present in community_cookbook.

The metadata.rb file in community_cookbook has the following dependency list.

...
depends mysql
depends postfix
...

So, by default the run-list has the latest version (say 8.3.0) of mysql cookbook.

My question is what changes should I be making in order to get previous version of mysql (say 5.3.6).

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

What steps did I take to solve this problem ?

Ans:

I wrote the following in metadata.rb of my_cookbook.

...
    depends 'mysql', '~> 5.6.3'
    depends 'community_cookbook', '~> 1.1.0' 
...

And I got this following message on the console

>>>>>>     Failed to complete #converge action: [Unable to satisfy the following requirements:

- `mysql (= 8.3.0)` required by `user-specified dependency`
- `mysql (~> 5.6.3)` required by `my_cookbook-0.1.0`
- `mysql (>= 0.0.0)` required by `community_cookbook-1.1.0`
- `mysql (>= 6.0.0)` required by `php-3.0.0`  # This is because the community_cookbook also has php as it's dependency list. 

Upvotes: 1

Views: 2617

Answers (2)

Deepak
Deepak

Reputation: 746

You might have changed the Berksfile.lock manually and it is causing the above issue.

can you try to deleting Berksfile.lock(take backup) and do berks install and then upload?

it should install all the necessary version of mysql cookbook and then all the cookbook can have the mysql version they require

Upvotes: 1

coderanger
coderanger

Reputation: 54249

It sounds like you have something funky in your Berkfile or Policyfile. Check for unintended version pins there and possibly run berks update to force a re-solve. The user-specified-dependency means that constraint is coming from outside the cookbook system, usually via a manual cookbook 'mysql', '8.3.0' in a Berksfile but there are other ways like environment constraints or run list version hacks.

Upvotes: 0

Related Questions