Search code examples
rubychef-inframetadataaws-opsworkscookbook

Unable to add cookbook dependency in metadata.rb chef


I am trying to include my abc-cookbook which has a ruby service installed in metadata.rb of another cookbook (say xyz-cookbook) which i have to launch. But while deploying the instance in opswork my setup is failing with an error as :

STDERR: Unable to satisfy constraints on package abc-cookbook, which does not exist, due to solution constraint (xyz-cookbook = 0.1.0). Solution constraints that may result in a constraint on abc-cookbook: [(xyz-cookbook = 0.1.0) -> (abc-cookbook >= 0.0.0)]
Missing artifacts: abac-cookbook
Demand that cannot be met: (xyz-cookbook = 0.1.0)
Unable to find a solution for demands: activemq (1.3.3), apacheds (0.1.0), apt (
---- End output of /opt/aws/opsworks/local/bin/berks vendor /opt/aws/opsworks/current/berkshelf-cookbooks ----
Ran /opt/aws/opsworks/local/bin/berks vendor /opt/aws/opsworks/current/berkshelf-cookbooks returned 106


Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage1/cookbooks/opsworks_commons/libraries/shellout.rb:9:in `shellout'
/var/lib/aws/opsworks/cache.stage1/cookbooks/opsworks_berkshelf/providers/runner.rb:13:in `block (3 levels) in class_from_file'


Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage1/cookbooks/opsworks_berkshelf/providers/runner.rb

11:   ruby_block 'Install the cookbooks specified in the Berksfile and their dependencies' do
12:     block do
13:       Chef::Log.info OpsWorks::ShellOut.shellout(
14:         berks_install_command,
15:         :cwd => ::File.dirname(OpsWorks::Berkshelf.berksfile),
16:         :environment  => {
17:           "BERKSHELF_PATH" => Opsworks::InstanceAgent::Environment.berkshelf_cache_path,
18:           "LC_ALL" => "en_US.UTF-8"
19:         }
20:       )
21: 
22:       ::FileUtils.rm_rf Opsworks::InstanceAgent::Environment.berkshelf_cache_path
23:     end
24: 
25:     only_if do
26:       OpsWorks::Berkshelf.berkshelf_installed? && OpsWorks::Berkshelf.berksfile_available?
27:     end
28:   end
29: end



Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage1/cookbooks/opsworks_berkshelf/providers/runner.rb:11:in `block in class_from_file'

ruby_block("Install the cookbooks specified in the Berksfile and their dependencies") do
action "run"
retries 0
retry_delay 2
block_name "Install the cookbooks specified in the Berksfile and their dependencies"
cookbook_name "opsworks_berkshelf"
block #<Proc:0x0055813e8bcb70@/var/lib/aws/opsworks/cache.stage1/cookbooks/opsworks_berkshelf/providers/runner.rb:12>
only_if { #code block }
end



[2016-01-08T12:33:45+00:00] INFO: Running queued delayed notifications before re-raising exception
[2016-01-08T12:33:45+00:00] ERROR: Running exception handlers
[2016-01-08T12:33:45+00:00] ERROR: Exception handlers complete
[2016-01-08T12:33:45+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage1/chef-stacktrace.out
[2016-01-08T12:33:45+00:00] ERROR: ruby_block[Install the cookbooks specified in the Berksfile and their dependencies] (/var/lib/aws/opsworks/cache.stage1/cookbooks/opsworks_berkshelf/providers/runner.rb line 11) had an error: Mixlib::ShellOut::ShellCommandFailed

Also I have added the dependency in xyz-cookbook metadata.rb as :

name             'xyz-cookbook'
maintainer       ''
maintainer_email ''
license          'All rights reserved'
description      'Installs/Configures create'
long_description 'Installs/Configures create'
version          '0.1.0'
depends          'abc-cookbook'

What am I missing and what is the error actually..


Solution

  • I did resolve this by adding dependency in my root Berksfile, which i missed even though i included my cookbook in another custom cookbook. This helped me :

    Important

    Do not declare cookbooks by including a metadata line in your Berksfile and declaring the cookbook dependencies in metadata.rb. For this to work correctly, both files must be in the same directory. With AWS OpsWorks, the Berksfile must be in the repository's root directory, but metadata.rb files must be in their respective cookbook directories. You should instead explicitly declare external cookbooks in the Berksfile