rubyrubygemschef-infratest-kitchenberkshelf

Test Kitchen Vagrant Berkshelf


With the following software versions installed: Berkshelf - 2.0.18 Ruby - 2.2.2 Vagrant - 1.9.3 test-kitchen - 1.15.0 kitchen-vagrant - 1.1.0 Chef Server API version - 11.0.2

I am attempting to run test kitchen on my local system. In doing so, I have a berksfile that points to a chef_api :config with a single recipe apt

chef_api :config

cookbook 'apt'

The config is based on my knife.rb configuration. I do most of my gem installs via bundler Here is my gem file

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

Here is the .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]

I am able to get the bundle install to work and run the berks install to work fine. However, when I run a kitchen converge the system deploys but then gets to the point of deploying the cookbooks and fails with the following message:

-----> 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

I then reviewed the logs and it appears to be coming from the 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-----

In reviewing the gem berksfile.rb file there is a object created using the berksfile and then this object is eventually called with the vendor method, which does not exists. I am not sure where to take this at this point. If anyone can provide some assistance on this issue, it would be greatly appreciated. I am stuck on these specific versions due to the chef server version we are on.

Based on what I have read in the docs, the latter versions of Berkshelf require a Berkshelf API version or Chef API version 12.4 or higher. Unfortunately neither is possible to attain in my situation


Solution

  • After some research and digging around, I was able to get this to work with the following

    Gemfile:

      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
    

    It is not ideal but for anyone in a similar situation. This is works as expected.