【问题标题】:Test Kitchen Vagrant Berkshelf测试厨房流浪者Berkshelf
【发布时间】:2017-04-17 10:44:55
【问题描述】:

安装了以下软件版本: Berkshelf - 2.0.18 红宝石 - 2.2.2 流浪者 - 1.9.3 测试厨房 - 1.15.0 厨房流浪者 - 1.1.0 Chef 服务器 API 版本 - 11.0.2

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

chef_api :config

cookbook 'apt'

该配置基于我的knife.rb 配置。 我的大部分 gem 安装都是通过 bundler 完成的 这是我的宝石文件

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]

我能够让捆绑安装工作并运行 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

然后我查看了日志,它似乎来自 test-kitchen 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 创建的对象,然后该对象最终使用 vendor 方法调用,但该方法不存在。我现在不知道在哪里采取这个。如果有人可以在这个问题上提供一些帮助,将不胜感激。由于我们使用的是主厨服务器版本,我被困在这些特定版本上。

根据我在文档中阅读的内容,Berkshelf 的后一版本需要 Berkshelf API 版本或 Chef API 版本 12.4 或更高版本。不幸的是,在我的情况下两者都无法实现

【问题讨论】:

    标签: ruby rubygems chef-infra test-kitchen berkshelf


    【解决方案1】:

    经过一些研究和挖掘,我能够让它与以下内容一起工作

    宝石文件:

      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
    

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 我在问题中添加了其他信息。根据我发现由于我们正在使用的 Chef Server 的版本,使用不同的版本是不可能的。
      • 我们添加berks API端点的全部原因是因为那个时代的Berks基本上根本不起作用,它必须在版本解决方案上作弊。与 Berks 2.x 相比,您最好手动管理依赖项。我们不支持它,它远远超出使用寿命。
      • 如果你想活在过去,你只需要使用 2014 年的版本。这就是我们现在分发快照安装程序 (ChefDK) 的原因。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-10
      • 2015-04-27
      • 1970-01-01
      • 2015-02-10
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      相关资源
      最近更新 更多