【问题标题】:Unable to find rbenv cookbook with default Chef kitchen setup, chef_zero, Berkshelf无法找到具有默认 Chef 厨房设置、chef_zero、Berkshelf 的 rbenv 食谱
【发布时间】:2015-12-29 17:52:09
【问题描述】:

我正在尝试创建一个 Chef 食谱,用于配置具有 rbenv、Postgres 和 JDK 的机器,但我遇到了依赖问题。

我使用(如果我没记错的话)chef generate app chef-project 创建了一个 Chef 存储库,并开始将规格放在一起。当需要使用 rbenv cookbook 改进食谱时,我将其添加到 Berksfile:

source 'https://supermarket.chef.io'

metadata

cookbook 'rbenv', '= 1.4.1'

并在配方中引用它:

#
# Cookbook Name:: chef-project
# Recipe:: default
#
# Copyright (c) 2015 The Authors, All Rights Reserved.

# Install rbenv

include_recipe 'rbenv::default'
include_recipe 'rbenv::ruby_build'

# Install jruby

rbenv_ruby 'jruby-1.7.19'

# Install bundler

rbenv_gem 'bundler' do
  ruby_version 'jruby-1.7.19'
end

package 'default-jdk'
package 'postgresql'

但是,它给了我这个错误:

-----> Converging <default-ubuntu-1404>...
       Preparing files for transfer
       Preparing dna.json
       Preparing cookbooks from project directory
       Removing non-cookbook files before transfer
       Preparing validation.pem
       Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
       Transferring files to <default-ubuntu-1404>
       Starting Chef Client, version 12.6.0
       resolving cookbooks for run list: ["chef-project::default"]
       Synchronizing Cookbooks:
         - chef-project (0.1.0)
       Compiling Cookbooks...
       [2015-12-29T17:41:08+00:00] WARN: MissingCookbookDependency:
       Recipe `rbenv::default` is not in the run_list, and cookbook 'rbenv'
       is not a dependency of any cookbook in the run_list.  To load this recipe,
       first add a dependency on cookbook 'rbenv' in the cookbook you're
       including it from in that cookbook's metadata.


       ================================================================================
       Recipe Compile Error in /tmp/kitchen/cache/cookbooks/chef-project/recipes/default.rb
       ================================================================================

       Chef::Exceptions::CookbookNotFound
       ----------------------------------
       Cookbook rbenv not found. If you're loading rbenv from another cookbook, make sure you configure the dependency in your metadata

       Cookbook Trace:
       ---------------
         /tmp/kitchen/cache/cookbooks/chef-project/recipes/default.rb:9:in `from_file'

       Relevant File Content:
       ----------------------
       /tmp/kitchen/cache/cookbooks/chef-project/recipes/default.rb:

         2:  # Cookbook Name:: chef-project
         3:  # Recipe:: default
         4:  #
         5:  # Copyright (c) 2015 The Authors, All Rights Reserved.
         6:
         7:  # Install rbenv
         8:
         9>> include_recipe 'rbenv::default'
        10:  include_recipe 'rbenv::ruby_build'
        11:
        12:  # Install jruby
        13:
        14:  rbenv_ruby 'jruby-1.7.19'
        15:
        16:  # Install bundler
        17:
        18:  rbenv_gem 'bundler' do


       Running handlers:
       [2015-12-29T17:41:08+00:00] ERROR: Running exception handlers

       [2015-12-29T17:41:08+00:00] ERROR: Exception handlers complete

       [2015-12-29T17:41:08+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2015-12-29T17:41:08+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2015-12-29T17:41:08+00:00] ERROR: Cookbook rbenv not found. If you're loading rbenv from another cookbook, make sure you configure the dependency in your metadata
       [2015-12-29T17:41:09+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

depends 'rbenv' 添加到食谱的metadata.rb 并不能解决问题 - 它仍然给我一个关于找不到rbenv 的错误。我还需要做些什么来将其添加为依赖项吗?

回购看起来像这样:

.
├── README.md
├── cookbooks
│   └── chef-project
│       ├── Berksfile
│       ├── Berksfile.lock
│       ├── chefignore
│       ├── metadata.rb
│       ├── recipes
│       │   └── default.rb
│       └── spec
│           ├── spec_helper.rb
│           └── unit
│               └── recipes
│                   └── default_spec.rb
└── test
    └── integration
        ├── default
        │   └── serverspec
        │       └── default_spec.rb
        └── helpers
            └── serverspec
                └── spec_helper.rb

而我的.kitchen.yml 看起来像这样:

---
driver:
  name: vagrant

provisioner:
  name: chef_zero

# Uncomment the following verifier to leverage Inspec instead of Busser (the
# default verifier)
# verifier:
#   name: inspec

platforms:
  - name: ubuntu-14.04

suites:
  - name: default
    run_list:
      - recipe[chef-project::default]
    attributes:

编辑:使用chef_solo 而不是chef_zero 给了我同样的问题,所以没有骰子。

【问题讨论】:

标签: chef-infra berkshelf test-kitchen


【解决方案1】:

您不想将其放入 Berksfile,而是要将其添加到您的 metadata.rb

depends 'rbenv', '1.4.1'

这告诉 Chef 将其作为依赖项加载,仅将其添加到 Berksfile 不会。

【讨论】:

  • 我将其添加到 metadata.rb,并将其从 Berksfile 中删除。我现在收到No such cookbook: rbenv 错误。我是否需要实际下载食谱本身?
  • .kitchen.yml 在哪个文件夹中(您在哪里运行kitchen test,可能是同一个文件夹)?看起来您正在尝试在非默认布局的单存储库布局中使用厨房。
猜你喜欢
  • 1970-01-01
  • 2020-09-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多