【问题标题】:Unable to add cookbook dependency in metadata.rb chef无法在 metadata.rb chef 中添加食谱依赖项
【发布时间】:2016-04-13 04:39:57
【问题描述】:

我正在尝试将我的 abc-cookbook 包含在我必须启动的另一本食谱(比如 xyz-cookbook)的 metadata.rb 中安装的 ruby​​ 服务。 但是在 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'

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

【问题讨论】:

  • 您的自定义食谱中是否包含abc-cookbookxyz-cookbook?您是否在 Stack 中使用 Berkshelf,如果没有,请仔细检查它是否已禁用,在我看来,Stack 认为它已启用。如果已启用,请发布您的 Berksfile 以及您的自定义食谱路径是什么样的

标签: ruby chef-infra metadata aws-opsworks cookbook


【解决方案1】:

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

重要

不要通过在您的文件中包含元数据行来声明食谱 Berksfile 并在 metadata.rb 中声明食谱依赖项。为了 要正常工作,两个文件必须位于同一目录中。和 AWS OpsWorks,Berksfile 必须位于存储库的根目录中 目录,但 metadata.rb 文件必须在各自的说明书中 目录。相反,您应该明确声明外部说明书 在 Berksfile 中

【讨论】:

    猜你喜欢
    • 2017-10-25
    • 2014-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-06
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多