Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* winrm.ssl_peer_verification must be a boolean. #327

Open
mirogta opened this issue Sep 14, 2017 · 2 comments
Open

* winrm.ssl_peer_verification must be a boolean. #327

mirogta opened this issue Sep 14, 2017 · 2 comments

Comments

@mirogta
Copy link

mirogta commented Sep 14, 2017

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

@cheeseplus
Copy link
Contributor

Should be solved by #330 but if not let us know!

@mirogta
Copy link
Author

mirogta commented Jun 1, 2018

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]

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

No branches or pull requests

3 participants