TrinitronX
TrinitronX

Reputation: 5203

chef_zero provisioner won't work in test-kitchen

When testing out the chef_zero provisioner in the OpsCode test-kitchen tool, I am seeing the following error:

$ bundle exec kitchen test
-----> Starting Kitchen (v1.1.1)
-----> Cleaning up any prior instances of <default-ubuntu-1004>
-----> Destroying <default-ubuntu-1004>...
       ==> default: Forcing shutdown of VM...
       ==> default: Destroying VM and associated drives...
       Vagrant instance <default-ubuntu-1004> destroyed.
       Finished destroying <default-ubuntu-1004> (0m4.62s).
-----> Testing <default-ubuntu-1004>
-----> Creating <default-ubuntu-1004>...
       Bringing machine 'default' up with 'virtualbox' provider...
       ==> default: Importing base box 'opscode-ubuntu-10.04'...
       ==> default: Matching MAC address for NAT networking...
       ==> default: Setting the name of the VM: default-ubuntu-1004_default_1402458172208_54996
       Skipping Berkshelf with --no-provision
       ==> default: Clearing any previously set network interfaces...
       ==> default: Preparing network interfaces based on configuration...
           default: Adapter 1: nat
       ==> default: Forwarding ports...
           default: 22 => 2222 (adapter 1)
       ==> default: Running 'pre-boot' VM customizations...
       ==> default: Booting VM...
       ==> default: Waiting for machine to boot. This may take a few minutes...
           default: SSH address: 127.0.0.1:2222
           default: SSH username: vagrant
           default: SSH auth method: private key
           default: Warning: Connection timeout. Retrying...
       ==> default: Machine booted and ready!
       ==> default: Checking for guest additions in VM...
           default: The guest additions on this VM do not match the installed version of
           default: VirtualBox! In most cases this is fine, but in rare cases it can
           default: prevent things such as shared folders from working properly. If you see
           default: shared folder errors, please make sure the guest additions within the
           default: virtual machine match the version of VirtualBox you have installed on
           default: your host and reload your VM.
           default:
           default: Guest Additions Version: 4.2.6
           default: VirtualBox Version: 4.3
       ==> default: Setting hostname...
       ==> default: Machine not provisioning because `--no-provision` is specified.
       Vagrant instance <default-ubuntu-1004> created.
       Finished creating <default-ubuntu-1004> (0m36.52s).
-----> Converging <default-ubuntu-1004>...
       Preparing files for transfer
       Resolving cookbook dependencies with Berkshelf...
       Removing non-cookbook files before transfer
       Transfering files to <default-ubuntu-1004>
       /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-cli-1.3.0/lib/mixlib/cli.rb:226:in `parse_options': invalid option: -z (OptionParser::InvalidOption)
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/lib/chef/application.rb:78:in `configure_chef'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/lib/chef/application.rb:65:in `reconfigure'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/lib/chef/application/client.rb:217:in `reconfigure'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/lib/chef/application.rb:71:in `run'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.2.0/bin/chef-client:26:in `<top (required)>'
        from /usr/bin/chef-client:23:in `load'
        from /usr/bin/chef-client:23:in `<main>'
>>>>>> Converge failed on instance <default-ubuntu-1004>.
>>>>>> Please see .kitchen/logs/default-ubuntu-1004.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-client -z --config /tmp/kitchen/client.rb --json-attributes /tmp/kitchen/dna.json --log_level info]
>>>>>> ----------------------

It seems to be running chef-client with the -z flag, but it's returning an error that this is an invalid option.

How do I fix this?

Upvotes: 1

Views: 2417

Answers (1)

TrinitronX
TrinitronX

Reputation: 5203

The problem might be that the bento box which test-kitchen is using for platform ubuntu-1004 was not built with a new enough version of chef pre-installed. Therefore, the -z flag for using chef_zero provisioner is not available!

To fix this, make sure to set require_chef_omnibus: latest in .kitchen.yml:

---
driver:
  name: vagrant
driver_config:
  require_chef_omnibus: latest

provisioner:
  name: chef_zero

platforms:
  - name: ubuntu-10.04
  - name: ubuntu-12.04
  - name: ubuntu-12.10
  - name: ubuntu-13.04
  - name: ubuntu-13.10

suites:
  - name: default
    run_list:
     - recipe[make-me-a-sammich::default]
    attributes:

EDIT:

It also might be that you have an older version of the OpsCode ubuntu-1004 bento box cached locally. The newer bento boxes are all provisionerless as @sethvargo pointed out. If this is the case, you can try fixing it by moving the old cached box first, then re-trying the kitchen test command:

mv ~/.vagrant.d/boxes/opscode-ubuntu-10.04 ~/.vagrant.d/tmp/opscode-ubuntu-10.04
bundle exec kitchen test ubuntu-1004 -d never

If this fixes your problem, you had a bad cached box on your system!

Upvotes: 2

Related Questions