kitchen-vagrant
kitchen-vagrant copied to clipboard
* winrm.ssl_peer_verification must be a boolean.
There is a bug in https://github.com/test-kitchen/kitchen-vagrant/blob/master/templates/Vagrantfile.erb
on line 71:
c.winrm.<%= key %> = "<%= value %>"
That code assumes the value will be always wrapped in double quotes which produces e.g. c.winrm.ssl_peer_verification = "false"
But that is wrong, because for boolean values it must not be wrapped in double quotes.
If I have set up the following driver config:
platform:
- name: windows-2012R2
driver:
box: kensykora/windows_2012_r2_standard
cache_directory: D:/Cache
winrm:
transport: plaintext # negotiate | ssl | plaintext
ssl_peer_verification: false
transport:
name: winrm
elevated: true
compression: none
It will fail with the following error:
------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: Bringing machine 'default' up with 'virtualbox' provider... STDERR: There are errors in the configuration of this machine. Please fix the following errors and try again:
WinRM:
- winrm.ssl_peer_verification must be a boolean. ---- End output of vagrant up --no-provision --provider virtualbox ---- Ran vagrant up --no-provision --provider virtualbox returned 1] on default-windows-2012R2
Please see .kitchen/logs/kitchen.log for more details Also try running
kitchen diagnose --all
for configuration
Should be solved by #330 but if not let us know!
Hi, first apologies for the delay in reply.
The fix didn't work unfortunately, because the if value.is_a? String
added in the commit doesn't work as expected (on my ruby version on Windows).
Part of my .kitchgen.yml
:
...
winrm:
transport: 'plaintext'
ssl_peer_verification: false
basic_auth_only: true
disable_sspi: true
username: 'Vagrant'
passport: 'vagrant'
...
Before the #300, the Vagrantfile was generated with:
c.winrm.transport = "plaintext"
c.winrm.ssl_peer_verification = "false"
c.winrm.basic_auth_only = "true"
c.winrm.disable_sspi = "true"
c.winrm.username = "Vagrant"
c.winrm.passport = "vagrant"
After the #300 fix, the Vagrantfile is generated with:
c.winrm.transport = plaintext
c.winrm.ssl_peer_verification = false
c.winrm.basic_auth_only = true
c.winrm.disable_sspi = true
c.winrm.username = Vagrant
c.winrm.passport = vagrant
... which obviously doesn't work.
I was able to make it work with the following hack in \templates\Vagrantfile.erb
instead:
<% if config[:winrm] %>
<% config[:winrm].each do |key, value| %>
<% formatted_value = case value
when true
true
when false
false
else
"\"#{value}\""
end
%>
c.winrm.<%= key %> = <%= formatted_value %>
<% end %>
<% end %>
... but that obviously won't work for e.g. numbers if you don't want them in quotes too.
Ruby version:
ruby 2.4.3p205 (2017-12-14 revision 61247) [x64-mingw32]