Simplified Cookbook Resolution

Sean Horn -

I am a user with the following set of cookbooks and I expect chef server's dependency resolution system to lock the versions of "linux_role" and "app1" to versions 1.0.1 and 1.0.3, respectively, as shown. I will implement the version control scheme as detailed in the Cookbook Metadata section further below.

Name Version
linux_role 1.0.1
app1_environment 0.1.0
app1_role 1.0.9
app1 1.0.3

I expect the following list of dependencies to be used, at minimum, when the chef-client goes to resolve the cookbook versions.

[2015-04-09T16:54:13+00:00] INFO: Loading cookbooks [linux_role@1.0.1, app1_environment@0.1.0, app1_role@1.0.0, app1@1.0.3]

To test, I started out creating the following list of cookbooks and versions and adjusted the metadata.rb dependencies and tried to converge, which failed, because of the settings in the metadata.rb files for various cookbooks.

Name Version
linux_role 0.1.0
app1_environment 0.1.0
app1_role 0.1.0
app1 0.1.0

Then, I just changed the metadata.rb for each one as failures to converge occurred, following the constraints.

The following failed with dependency issues in order

linux_role
app1_role
app1

Cookbook Metadata


I fixed each issue as they came up with the following edits in order, referring to the output from

chef-client -z -l debug -r recipe[linux_role],recipe[app1_environment],recipe[app1_role],recipe[app1]

as I went.

[vagrant@default-chef-centos-65 kitchen]$ cat cookbooks/linux_role/metadata.rb

name 'linux_role' maintainer 'YOUR_COMPANY_NAME' maintainer_email 'YOUR_EMAIL' license 'All rights reserved' description 'Installs/Configures linux_role' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) #version '0.1.0' version '1.0.1'
[vagrant@default-chef-centos-65 kitchen]$ cat cookbooks/app1_role/metadata.rb

name 'app1_role' maintainer 'YOUR_COMPANY_NAME' maintainer_email 'YOUR_EMAIL' license 'All rights reserved' description 'Installs/Configures app1_role' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) #version '0.1.0' version '1.0.0' depends 'linux_role', '= 1.0.1' # hard constraint depends 'app1', '= 1.0.3' # hard constraint
[vagrant@default-chef-centos-65 kitchen]$ cat cookbooks/app1/metadata.rb

name 'app1' maintainer 'YOUR_COMPANY_NAME' maintainer_email 'YOUR_EMAIL' license 'All rights reserved' description 'Installs/Configures app1' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) #version '0.1.0' version '1.0.3' depends 'linux_role' # No version constraint, rely on role cookbook version constraint!


If I define the version of "app1_role" this way

version '1.1.0'

And then try to converge, I get

[2015-04-09T17:13:37+00:00] INFO: HTTP Request Returned 412 Precondition Failed : Could not satisfy version constraints for: app1_role
================================================================================Error Resolving Cookbooks for Run List:================================================================================

Missing Cookbooks:
------------------
Could not satisfy version constraints for: app1_role
Expanded Run List: ------------------
* linux_role * app1_environment * app1_role * app1

Because "app1_environment" includes this statement which only allows "app1_role" to range up to version "1.0.9"

depends 'app1_role', '~> 1.0.0'

I ended up with the following working set of versions. If I vary the versions of "linux_role" or "app1", it causes a resolution error, as expected, because those versions are completely locked down.

Name Version
linux_role 1.0.1
app1_environment 0.1.0
app1_role 1.0.9
app1 1.0.3

More detailed information about cookbook resolution can be found at Troubleshoot Cookbook Dependency Issues

Have more questions? Submit a request

Comments

Powered by Zendesk