无法在metadata.rb chef中添加cookbook依赖项

时间:2016-01-08 13:17:06

标签: ruby chef metadata aws-opsworks cookbook

我正在尝试包含我的abc-cookbook,其中有一个ruby服务安装在另一本食谱(比如xyz-cookbook)的metadata.rb中,我必须启动它。 但是,当在opswork中部署实例时,我的设置失败并出现错误:

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

此外,我已将xyz-cookbook metadata.rb中的依赖项添加为:

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'

我错过了什么,实际上错误是什么..

1 个答案:

答案 0 :(得分:1)

我通过在我的根Berksfile中添加依赖来解决这个问题,即使我将我的食谱包含在另一个自定义食谱中,我也错过了。 这对我有所帮助:

  

重要

     

不要通过在您的网站中添加元数据行来声明食谱   Berksfile并在metadata.rb中声明cookbook依赖项。对于   这要正常工作,两个文件必须在同一目录中。同   AWS OpsWorks,Berksfile必须位于存储库的根目录中   目录,但metadata.rb文件必须在各自的cookbook中   目录。您应该明确声明外部cookbook   在Berksfile中