chef-boneyard / vagrant-omnibus

A Vagrant plugin that ensures the desired version of Chef is installed via the platform-specific Omnibus packages.
Apache License 2.0
550 stars 63 forks source link

Undefined method 'sh' for VagrantPlugins CommunicatorWinRM #90

Open chriskilding opened 10 years ago

chriskilding commented 10 years ago

This issue has been migrated from (#4249)[https://github.com/mitchellh/vagrant/issues/4249] in Vagrant core, after @sneal found it to be a bug with this plugin instead.


I got the following error when trying to provision a Windows Server 2008 R2 box with Chef Solo and vagrant-omnibus. A cursory look suggests something thought it was in *nix land and called 'sh' when it shouldn't have done.

The box I'm using is https://vagrantcloud.com/ferventcoder/win2008r2-x64-nocm. Running on Vagrant 1.6.3 / OSX 10.9 / latest Chef development kit with integrated Berkshelf.

==> windows: Mounting shared folders...
    windows: /vagrant => /Users/[me]/Documents/Git/rtsproto_backend
    windows: /tmp/vagrant-chef-2/chef-solo-1/cookbooks => /Users/[me]/.berkshelf/windows/vagrant/berkshelf-20140725-1855-1muei20-windows
==> windows: Forcing shutdown of VM...
==> windows: Destroying VM and associated drives...
==> windows: Running cleanup tasks for 'chef_solo' provisioner...
/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/plugins/communicators/winrm/communicator.rb:76:in `execute': undefined method `sh' for #<VagrantPlugins::CommunicatorWinRM::WinRMShell:0x000001009dab10> (NoMethodError)
    from /Users/[me]/.vagrant.d/gems/gems/vagrant-omnibus-1.4.1/lib/vagrant-omnibus/action/install_chef.rb:144:in `installed_version'
...
ryancragun commented 10 years ago

I'm seeing the same thing here:

/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/plugins/communicators/winrm/communicator.rb:76:in `execute': undefined method `sh' for #<VagrantPlugins::CommunicatorWinRM::WinRMShell:0x0000010360c030> (NoMethodError)
    from /Users/nc014943/.vagrant.d/gems/gems/vagrant-omnibus-1.4.1/lib/vagrant-omnibus/action/install_chef.rb:144:in `installed_version'
    from /Users/nc014943/.vagrant.d/gems/gems/vagrant-omnibus-1.4.1/lib/vagrant-omnibus/action/install_chef.rb:47:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/builtin/provision.rb:80:in `call```

It should be set to ':cmd' but the windows guest detection is broken

def windows_guest?
  @machine.config.vm.guest.eql?(:windows)
end

@machine.config.vm.guest is nil so it's incorrectly detecting a non-windows guest.

fabriciocolombo commented 10 years ago

I have a machine running on a host windows and had no problems. My VagrantFile is like this:

 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   config.vm.box = "ferventcoder/win2008r2-x64-nocm"  
   config.vm.communicator = "winrm"
   config.vm.guest = :windows
   ...
end

Vagrant 1.6.3 vagrant-omnibus (1.4.1) Host Windows 7 Professional x64

sneal commented 10 years ago

I would consider config.vm.guest = :windows a (good) workaround. Vagrant 1.6+ uses the communicator type to figure out if it should use WinRM or SSH, and thus shell type. Vagrant doesn't require you to set the guest type to windows like the old vagrant-windows plugin.

It would be good to have the check be consistent between any plugins and Vagrant core.

vinyar commented 9 years ago

+1 just hit this as well. Adding below fixed the error.

   config.vm.guest = :windows

With that said, I would wager a guess that guest :windows is an artifact left behind to avoid breaking people after vagrant started officially supporting windows (I think guest :windows essentially translates into communicator = 'winrm'. It may go away at some point.

sneal commented 9 years ago

@vinyar Guest and Communicator seem similar, but are very different. For example, you can set the guest type to 'windows' and the communicator to 'ssh' assuming you've installed and configured an SSH server on your Windows guest.

lonniev commented 9 years ago

Thanks @sneal this also immediately fixed the omnibus issue for me for a Windows on Softlayer VM.