测试厨房 Vagrant Berkshelf

Test Kitchen Vagrant Berkshelf

安装了以下软件版本: 伯克谢尔夫 - 2.0.18 Ruby - 2.2.2 流浪汉 - 1.9.3 测试厨房 - 1.15.0 厨房流浪汉 - 1.1.0 厨师服务器 API 版本 - 11.0.2

我正在尝试 运行 在我的本地系统上测试厨房。 在这样做的过程中,我有一个指向 chef_api :config 的 berksfile 和一个配方 apt

chef_api :config

cookbook 'apt'

配置基于我的knife.rb配置。 我的大部分 gem 安装都是通过捆绑器完成的 这是我的 gem 文件

source 'https://artifactory.mia.ucloud.int/artifactory/api/gems/rubygems' do

    gem 'berkshelf', '~> 2.0.18'
    gem 'celluloid', '~> 0.16.0'
    gem 'celluloid-io', '~> 0.16.1'
    gem 'net-http-persistent', '~> 2.9.0'
    gem 'test-kitchen'
    gem 'kitchen-vagrant'

end

这是.kitchen.yml:

---
driver:
   name: vagrant

provisioner:
  name: chef_solo

platforms:
  - name: ubuntu-14.04
    driver:
      box: ubuntu/trusty64

suites:
  - name: default
    run_list:
      - recipe[apt::default]
      - recipe[git::server]
    attributes:
   - name: core
     run_list: 
      - recipe[ultimate_metadefender_core::default]

我能够让 bundle 安装工作,运行 berks 安装工作正常。然而,当我 运行 厨房收敛时,系统部署但随后到达部署食谱的点并失败并显示以下消息:

-----> Starting Kitchen (v1.15.0)
-----> Converging <core-ubuntu-1404>...
       Preparing files for transfer
       Preparing dna.json
       Resolving cookbook dependencies with Berkshelf 2.0.18...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #converge action: [undefined method `vendor' for 
#<Berkshelf::Berksfile:0x007fdd3d161620>] on core-ubuntu-1404
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

然后我查看了日志,它似乎来自测试厨房 gem:

    -----> Converging <core-ubuntu-1404>...
    Preparing files for transfer
    Preparing dna.json
    Resolving cookbook dependencies with Berkshelf 2.0.18...
    Converge failed on instance <core-ubuntu-1404>.
    ------Exception-------
    Class: NoMethodError
    Message: undefined method `vendor' for #
    <Berkshelf::Berksfile:0x007fdd3d161620>
    ----------------------
    ------Backtrace-------

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef/berkshelf.rb:66:in `block in resolve'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/thor-0.18.1/lib/thor/shell/basic.rb:19:in `mute'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef/berkshelf.rb:61:in `resolve'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef/common_sandbox.rb:329:in `block in resolve_with_berkshelf'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef/common_sandbox.rb:326:in `synchronize'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef/common_sandbox.rb:326:in `resolve_with_berkshelf'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef/common_sandbox.rb:260:in `prepare_cookbooks'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef/common_sandbox.rb:48:in `populate'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef_base.rb:126:in `create_sandbox'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/chef_solo.rb:41:in `create_sandbox'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/provisioner/base.rb:65:in `call'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:384:in `block in converge_action'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/g
ems/test-kitchen-1.15.0/lib/kitchen/instance.rb:527:in `synchronize_or_call'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:489:in `block in action'
    /Users/miker/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/benchmark.rb:288:in `measure'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:488:in `action'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:380:in `converge_action'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:359:in `block in transition_to'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:358:in `each'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:358:in `transition_to'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/instance.rb:135:in `converge'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:197:in `public_send'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:197:in `run_action_in_thread'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/test-kitchen-1.15.0/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'

  /Users/miker/Projects/hp/cav/infrastructure/configuration/vendor/gems/ruby/2.2.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
    ----End Backtrace-----

在查看 gem berksfile.rb 文件时,有一个使用 berksfile 创建的对象,然后最终使用不存在的供应商方法调用了该对象。我不知道现在该把它带到哪里。如果有人可以就此问题提供一些帮助,将不胜感激。由于我们使用的是厨师服务器版本,我被困在这些特定版本上。

根据我在文档中阅读的内容,Berkshelf 的最新版本需要 Berkshelf API 版本或 Chef API 版本 12.4 或更高版本。不幸的是,在我的情况下都不可能实现

Berkshelf 2.0 很老,当前版本是5.x。我们仅支持通过 ChefDK 安装的 Berkshelf,因此请删除所有现有副本,然后通过正常的 ChefDK 安装程序进行安装。

经过一些研究和挖掘,我能够将其与以下内容一起使用

宝石文件:

  gem 'rspec', '~> 3.1.0'
  gem 'test-kitchen', '~> 1.0'
  gem 'berkshelf', '~> 2.0.0' # DO NOT UPDATE to 3.00
  gem 'celluloid', '~> 0.16.0' # Added due to bug in bundler ignoring lock file
  gem 'kitchen-vagrant', '~> 0.15.0'
  gem 'rest-client', '~> 1.6.7'
  gem 'json-schema', '~> 2.2.5'
  gem 'rb-fsevent', '0.9.5' # Added due to ruby restriction with ruby_dep
  gem 'rb-inotify', '0.9.5' # Added due to ruby restriction with ruby_dep
  gem 'rack', '1.6.0' #needed to force 

Gemfile.lock:

GEM
  remote: http://artifactory.mia.ucloud.int/artifactory/api/gems/rubygems/
  specs:
    activesupport (3.2.22.2)
      i18n (~> 0.6, >= 0.6.4)
      multi_json (~> 1.0)
    addressable (2.3.8)
    akami (1.3.1)
      gyoku (>= 0.4.0)
      nokogiri
    artifactory (2.3.2)
    berkshelf (2.0.18)
      activesupport (~> 3.2.0)
      addressable (~> 2.3.4)
      buff-shell_out (~> 0.1)
      chozo (>= 0.6.1)
      faraday (~> 0.8.5)
      hashie (~> 2.0)
      minitar (~> 0.5.4)
      rbzip2 (~> 0.2.0)
      retryable (~> 1.3.3)
      ridley (~> 1.7.0)
      solve (~> 0.8.2)
      thor (~> 0.18.0)
    buff-config (0.4.0)
      buff-extensions (~> 0.3)
      varia_model (~> 0.1)
    buff-extensions (0.5.0)
    buff-ignore (1.1.1)
    buff-ruby_engine (0.1.0)
    buff-shell_out (0.2.0)
      buff-ruby_engine (~> 0.1.0)
    builder (3.2.2)
    celluloid (0.16.0)
      timers (~> 4.0.0)
    celluloid-io (0.16.2)
      celluloid (>= 0.16.0)
      nio4r (>= 1.1.0)
    chozo (0.6.1)
      activesupport (>= 3.2.0)
      hashie (>= 2.0.2)
      multi_json (>= 1.3.0)
    diff-lcs (1.2.5)
    erubis (2.7.0)
    faraday (0.8.11)
      multipart-post (~> 1.2.0)
    ffi (1.9.10)
    gssapi (1.0.3)
      ffi (>= 1.0.1)
    gyoku (1.3.1)
      builder (>= 2.1.2)
    hashie (2.1.2)
    hitimes (1.2.4)
    httpclient (2.8.0)
    httpi (0.9.7)
      rack (= 1.6.0)
    i18n (0.7.0)
    json (1.8.1)
    json-schema (2.2.5)
    kitchen-vagrant (0.15.0)
      test-kitchen (~> 1.0)
    little-plugger (1.1.4)
    logging (1.8.2)
      little-plugger (>= 1.1.3)
      multi_json (>= 1.8.4)
    mime-types (1.25.1)
    mini_portile2 (2.0.0)
    minitar (0.5.4)
    mixlib-authentication (1.3.0)
      mixlib-log
    mixlib-install (1.0.11)
      artifactory
      mixlib-shellout
      mixlib-versioning
    mixlib-log (1.6.0)
    mixlib-shellout (1.6.1)
    mixlib-versioning (1.1.0)
    multi_json (1.12.0)
    multipart-post (1.2.0)
    net-http-persistent (2.9.4)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (2.9.4)
    nio4r (1.2.1)
    nokogiri (1.6.7.2)
      mini_portile2 (~> 2.0.0.rc2)
    nori (1.1.5)
    rack (1.6.0)
    rb-fsevent (0.9.5)
    rb-inotify (0.9.5)
      ffi (>= 0.5.0)
    rbzip2 (0.2.0)
    rest-client (1.6.9)
      mime-types (~> 1.16)
    retryable (1.3.6)
    ridley (1.7.1)
      addressable
      buff-config (~> 0.2)
      buff-extensions (~> 0.3)
      buff-ignore (~> 1.1)
      buff-shell_out (~> 0.1)
      celluloid (~> 0.15)
      celluloid-io (~> 0.15)
      erubis
      faraday (>= 0.8.4)
      hashie (>= 2.0.2)
      json (>= 1.7.7)
      mixlib-authentication (>= 1.3.0)
      net-http-persistent (>= 2.8)
      net-ssh
      retryable
      solve (>= 0.4.4)
      varia_model (~> 0.1)
      winrm (~> 1.1.0)
    rspec (3.1.0)
      rspec-core (~> 3.1.0)
      rspec-expectations (~> 3.1.0)
      rspec-mocks (~> 3.1.0)
    rspec-core (3.1.7)
      rspec-support (~> 3.1.0)
    rspec-expectations (3.1.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.1.0)
    rspec-mocks (3.1.3)
      rspec-support (~> 3.1.0)
    rspec-support (3.1.2)
    rubyntlm (0.1.1)
    safe_yaml (1.0.4)
    savon (0.9.5)
      akami (~> 1.0)
      builder (>= 2.1.2)
      gyoku (>= 0.4.0)
      httpi (~> 0.9)
      nokogiri (>= 1.4.0)
      nori (~> 1.0)
      wasabi (~> 1.0)
    solve (0.8.2)
    test-kitchen (1.7.3)
      mixlib-install (~> 1.0, >= 1.0.4)
      mixlib-shellout (>= 1.2, < 3.0)
      net-scp (~> 1.1)
      net-ssh (>= 2.9, < 4.0)
      safe_yaml (~> 1.0)
      thor (~> 0.18)
    thor (0.18.1)
    timers (4.0.4)
      hitimes
    uuidtools (2.1.5)
    varia_model (0.3.2)
      buff-extensions (~> 0.2)
      hashie (>= 2.0.2)
    wasabi (1.0.0)
      nokogiri (>= 1.4.0)
    winrm (1.1.3)
      gssapi (~> 1.0.0)
      httpclient (~> 2.2, >= 2.2.0.2)
      logging (~> 1.6, >= 1.6.1)
      nokogiri (~> 1.5)
      rubyntlm (~> 0.1.1)
      savon (= 0.9.5)
      uuidtools (~> 2.1.2)

PLATFORMS
  ruby

DEPENDENCIES
  berkshelf (~> 2.0.0)!
  celluloid (~> 0.16.0)!
  json-schema (~> 2.2.5)!
  kitchen-vagrant (~> 0.15.0)!
  rack (= 1.6.0)!
  rb-fsevent (= 0.9.5)!
  rb-inotify (= 0.9.5)!
  rest-client (~> 1.6.7)!
  rspec (~> 3.1.0)!
  test-kitchen (~> 1.0)!

BUNDLED WITH
   1.14.6

这并不理想,但对于任何处于类似情况的人来说。这是按预期工作的。