Skip to content

Instantly share code, notes, and snippets.

@shkrt
Last active September 30, 2017 06:49
Show Gist options
  • Save shkrt/480a9c9a1b91e3bbd9b321c0dbba75c5 to your computer and use it in GitHub Desktop.
Save shkrt/480a9c9a1b91e3bbd9b321c0dbba75c5 to your computer and use it in GitHub Desktop.

This temporary workaround is helpful, when test-kitchen is unable to connect to centos vm box via ssh with following error messages:

Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds

For kitchen create to work properly, one should create Vagrantfile.rb (extension is mandatory here) anywhere, and specify the path to this file in .kitchen.yml. The only content of this custom Vagrantfile is insert_key setting, because it's not being parsed properly by test-kitchen, when provided in .kitchen.yml.

# at the line 6 is a link to my custom Vagrantfile
---
driver:
name: vagrant
vagrantfiles:
- Vagrantfile
provisioner:
name: chef_zero
verifier:
name: inspec
platforms:
- name: centos-7.2
driver:
customize:
memory: 256
suites:
- name: default
run_list:
- recipe[motd_rhel::default]
attributes:
# contents of custom Vagrantfile
# the importants points are:
# - it has .rb extension, otherwise it would not be picked up by test kitchen
# - line 9, which prevents from ssh key insertion (which causes auth fail). This behaviour cannot be simply achieved
# by specifying insert_key: false in .kitchen.yml, because of the bug https://github.com/test-kitchen/kitchen-vagrant/issues/236
Vagrant.configure("2") do |c|
c.ssh.insert_key = false
end
@ziyan-junaideen
Copy link

Doesn't seem to be working with Windows. The generated Vagrant file has on top some thing like require "D:/Ziyan/Educational/Chef/chef/cookbooks/apache/Vagrantfile" and breaks with..

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider virtualbox ----
STDOUT:
STDERR: There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.


Path: D:/Ziyan/Educational/Chef/chef/cookbooks/apache/.kitchen/kitchen-vagrant/default-ubuntu-1604/Vagrantfile
Line number: 0
Message: LoadError: cannot load such file -- D:/Ziyan/Educational/Chef/chef/cookbooks/apache/Vagrantfile
---- End output of vagrant up --no-provision --provider virtualbox ----
Ran vagrant up --no-provision --provider virtualbox returned 1] on default-ubuntu-1604
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment