1
votes

While working with Chef, Kitchen, Vagrant and Virtual Box today... I encountered a bizarre issue when attempting to use the bento boxes hosted by Hashicorp (https://atlas.hashicorp.com/bento/) to do some Chef cookbook development/testing.

While spinning up a new cookbook, I wanted to test some newer versions of CentOS 7.2 and Ubuntu 16.04 which are not currently live in our environment. I turned to hashicorp's bento boxes to pull them down into my .kitchen.yml config.

.kitchen.yml

---
driver:
  name: vagrant

provisioner:
  name: chef_zero
  customize:
    memory: 1024

platforms:
  - name: ubuntu-16.04

suites:
  - name: default
    run_list:
      - recipe[sandbox::default]
    attributes:

Used chef generate cookbook to create a new cookbook and as you can see above, was using a very vanilla kitchen config to get things started.

When running kitchen create I kept encountering the following error as an SSH Timeout when provisioning the VM using Vagrant and Virtual Box.

ERROR:

Timed out while waiting for the machine to boot. 
This means that Vagrant was unable to communicate with the guest machine
within the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

When observing the Virtual Box VM Console, I noted the following (see screen shot below)...

A start job is running for Raise network interfaces (2 min 39s / 5min 3s)

VM Console Output

Observing that Vagrant would timeout prior to the start job completing... I attempted to resolve by increasing the boot_timeout from a default of 300 seconds to 600 seconds in my .kitchen.yml

However, further testing proved that this did not resolve the issue even though the VM would successfully initialize after 5mins 3s... Kitchen / Vagrant were unable to SSH to the Host and the failure and the Vagrant SSH timeout persisted.

1

1 Answers

2
votes

Ultimately, to resolve this issue I upgraded ChefDK, Vagrant, and VirtualBox to the latest versions available.

Experienced the issue with...

Virtual Box 5.0.30 r112061
Vagrant 1.8.6
Chef Development Kit 0.19.6

Resolved the issue by upgrading to...

Virtual Box 5.1.10 r112026
Vagrant 1.9.0
Chef Development Kit Version: 1.0.3

Following the version upgrades, the Vagrant SSH Timeouts disappeared completely and the box was created successfully within a few seconds.

Virtual Box VM Console

enter image description here