tknerr / vagrant-managed-servers

Enables Vagrant to ssh into and provision managed servers
MIT License
185 stars 30 forks source link

vagrant-winrm-syncedfolders plugin dependency is not installed as a vagrant plugin #49

Closed tknerr closed 8 years ago

tknerr commented 9 years ago

Looks like installing vagrant plugin install vagrant-managed-servers install the vagrant-winrm-syncedfolders plugin as a gem dependency only:

C:\Repos\_github\vagrant-managed-servers>vagrant plugin install vagrant-managed-servers
Installing the 'vagrant-managed-servers' plugin. This can take a few minutes...
Installed the plugin 'vagrant-managed-servers (0.7.0)'!

C:\Repos\_github\vagrant-managed-servers>vagrant plugin list
vagrant-berkshelf (4.0.4)
  - Version Constraint: 4.0.4
vagrant-cachier (1.2.0)
  - Version Constraint: 1.2.0
vagrant-managed-servers (0.7.0)
vagrant-omnibus (1.4.1)
  - Version Constraint: 1.4.1
vagrant-proxyconf (1.5.0)
  - Version Constraint: 1.5.0
vagrant-share (1.1.3, system)
vagrant-toplevel-cookbooks (0.2.4)
  - Version Constraint: 0.2.4
vagrant-winrm (0.7.0)
  - Version Constraint: 0.7.0

This way it's not registered with vagrant and thus the "winrm" synced folder mechanism is not detected.

C:\Repos\_github\vagrant-managed-servers>vagrant up local_windows
Bringing machine 'local_windows' up with 'virtualbox' provider...
==> local_windows: Importing base box 'boxcutter/eval-win7x86-enterprise'...
==> local_windows: Matching MAC address for NAT networking...
==> local_windows: Setting the name of the VM: vagrant-managed-servers_local_windows_1432283773317_82698
==> local_windows: Clearing any previously set network interfaces...
==> local_windows: Preparing network interfaces based on configuration...
    local_windows: Adapter 1: nat
    local_windows: Adapter 2: hostonly
==> local_windows: Forwarding ports...
    local_windows: 3389 => 3389 (adapter 1)
    local_windows: 5985 => 5985 (adapter 1)
    local_windows: 22 => 2222 (adapter 1)
==> local_windows: Running 'pre-boot' VM customizations...
==> local_windows: Booting VM...
==> local_windows: Waiting for machine to boot. This may take a few minutes...
==> local_windows: Machine booted and ready!
==> local_windows: Checking for guest additions in VM...
==> local_windows: Configuring and enabling network interfaces...
==> local_windows: Mounting shared folders...
    local_windows: /tmp/vagrant-cache => W:/home/.vagrant.d/cache/boxcutter/eval-win7x86-enterprise

C:\Repos\_github\vagrant-managed-servers>vagrant up managed_windows
==> managed_windows: The machine is backed by a cloud provider (managed), caching
==> managed_windows: will be disabled.
Bringing machine 'managed_windows' up with 'managed' provider...
==> managed_windows: Warning! The ManagedServers provider doesn't support any of the Vagrant
==> managed_windows: high-level network configurations (`config.vm.network`). They will be ignored.
==> managed_windows: Linking with managed server 192.168.40.36
==> managed_windows:  -- Server: 192.168.40.36

C:\Repos\_github\vagrant-managed-servers>vagrant provision managed_windows
==> managed_windows: The machine is backed by a cloud provider (managed), caching
==> managed_windows: will be disabled.
==> managed_windows: Warning! The ManagedServers provider doesn't support any of the Vagrant
==> managed_windows: high-level network configurations (`config.vm.network`). They will be ignored.
==> managed_windows: Rsyncing folder: /cygdrive/c/Repos/_github/vagrant-managed-servers/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /cygdrive/c/Repos/_github/vagrant-managed-servers/
Guest path: /vagrant
Command: rsync --verbose --archive --delete -z --copy-links --chmod=ugo=rwX --no-perms --no-owner --no-group -e ssh -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i 'W:/home/.vagrant.d/insecure_private_key' --exclude .vagrant/ /cygdrive/c/Repos/_github/vagrant-managed-servers/ vagrant@192.168.40.36:/vagrant
Error: Warning: Permanently added '192.168.40.36' (ECDSA) to the list of known hosts.
/bin/sh: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.1]

The workaround is to vagrant plugin install vagrant-winrm-syncedfolders manually.

tknerr commented 9 years ago

proof that the workaround works:

C:\Repos\_github\vagrant-managed-servers>vagrant plugin install vagrant-winrm-syncedfolders
Installing the 'vagrant-winrm-syncedfolders' plugin. This can take a few minutes...
Installed the plugin 'vagrant-winrm-syncedfolders (0.1.0)'!

C:\Repos\_github\vagrant-managed-servers>vagrant plugin list
vagrant-berkshelf (4.0.4)
  - Version Constraint: 4.0.4
vagrant-cachier (1.2.0)
  - Version Constraint: 1.2.0
vagrant-winrm-syncedfolders (0.1.0)
vagrant-managed-servers (0.7.0)
vagrant-omnibus (1.4.1)
  - Version Constraint: 1.4.1
vagrant-proxyconf (1.5.0)
  - Version Constraint: 1.5.0
vagrant-share (1.1.3, system)
vagrant-toplevel-cookbooks (0.2.4)
  - Version Constraint: 0.2.4
vagrant-winrm (0.7.0)
  - Version Constraint: 0.7.0

C:\Repos\_github\vagrant-managed-servers>vagrant provision managed_windows
==> managed_windows: The machine is backed by a cloud provider (managed), caching
==> managed_windows: will be disabled.
==> managed_windows: Warning! The ManagedServers provider doesn't support any of the Vagrant
==> managed_windows: high-level network configurations (`config.vm.network`). They will be ignored.
==> managed_windows: Uploading with WinRM: C:/Repos/_github/vagrant-managed-servers => /vagrant
tknerr commented 9 years ago

@chrisbaldauf ideas?

chrisbaldauf commented 9 years ago

Hmm, that's disappointing. Perhaps it could be addressed with documentation and remove the gem spec dependency? In vagrant-orchestrate, I use the required_plugins pattern where I lost all the plugins that I need to install for a project:

https://github.com/Cimpress-MCP/vagrant-orchestrate#plugins

The biggest downside that I can see to the documentation approach is that it could (most likely will) break anyone using this for Windows with a pre 0.7 version and require them to install a new plugin to get back to working.

I'll keep looking around.

chrisbaldauf commented 9 years ago

Or perhaps a new action that tests whether the host is Windows and the winrm syncedfolders plugin is installed with Vagrant.has_plugin? And prints a warning with a message including how to install. This feels like better reinforcement and is a cleaner but not totally clean upgrade path for those using Windows.

I found an example where a run fails until the plugin is installed: https://github.com/tkambler/perfect-vagrant/blob/08be599c0fb02d0401ef5bcac86ed3c7e41babe3/lib/required_plugins.rb

chrisbaldauf commented 9 years ago

A third option would be to fork the code and include it in VMS as we had it earlier in the pull request. Easiest for the user, since it just works but ugliest from a code maintenance standpoint. It isn't very much code though and we might be able to use something like git subtree.

chrisbaldauf commented 9 years ago

Taking the warning approach, I've got something that I think will be reasonable. Running locally with vagrant-winrm-syncedfolders not present in my Gemfile plugins section:

d:\dev\vagrant-managed-servers>bundle exec vagrant provision managed_windows
Your Gemfile lists the gem vagrant-managed-servers (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of
 just one of them later.
Vagrant appears to be running in a Bundler environment. Your
existing Gemfile will be used. Vagrant will not auto-load any plugins
installed with `vagrant plugin`. Vagrant will autoload any plugins in
the 'plugins' group in your Gemfile. You can force Vagrant to take over
with VAGRANT_FORCE_BUNDLER.

You appear to be running Vagrant outside of the official installers.
Note that the installers are what ensure that Vagrant has all required
dependencies, and Vagrant assumes that these dependencies exist. By
running outside of the installer environment, Vagrant may not function
properly. To remove this warning, install Vagrant using one of the
official packages from vagrantup.com.
==> managed_windows: Warning! The ManagedServers provider doesn't support any of
 the Vagrant
==> managed_windows: high-level network configurations (`config.vm.network`). Th
ey will be ignored.
==> managed_windows: Warning! The vagrant-winrm-syncedfolders plugin was not found and
==> managed_windows: is recommended for Windows guests. Install it with
==> managed_windows: `vagrant plugin install vagrant-winrm-syncedfolders`.
==> managed_windows: Preparing SMB shared folders...
    managed_windows: You will be asked for the username and password to use for
the SMB
    managed_windows: folders shortly. Please use the proper username/password of
 your
    managed_windows: Windows account.
    managed_windows:
    managed_windows: Username:
tknerr commented 9 years ago

Thanks! I'll double check on the mailing list for handling inter plugin dependencies, but all in all I like the documentation approach.

The warning in this case is useful too, but might be annoying if you want to use SMB. Would be ideal, if we could display it only when SMB didn't work, but guess that's not easily doable.

I'm fine with documentation only too, since we are not at 1.0 yet I don't mind too much about this backwards incompatibility with pre-0.7.0 winrm users, since there is an easy workaround.

chrisbaldauf commented 9 years ago

I wonder if it is as simple as referencing the dependent plugin from within the vagrant-managed-servers.rb. It was successfully loaded when the code was packaged with vms, so maybe we're just missing a require statement. Can you try to require "vagrant-winrm-syncedfolders" after line 3

On Fri, May 22, 2015 at 11:47 AM, Torben Knerr notifications@github.com wrote:

Thanks! I'll double check on the mailing list for handling inter plugin dependencies, but all in all I like the documentation approach.

The warning in this case is useful too, but might be annoying if you want to use SMB. Would be ideal, if we could display it only when SMB didn't work, but guess that's not easily doable.

I'm fine with documentation only too, since we are not at 1.0 yet I don't mind too much about this backwards incompatibility with pre-0.7.0 winrm users, since there is an easy workaround.

— Reply to this email directly or view it on GitHub https://github.com/tknerr/vagrant-managed-servers/issues/49#issuecomment-104695585 .

chrisbaldauf commented 9 years ago

I tried adding the require and it appears to have worked for me. PR coming and then we can try it packaged. Perhaps a pre-release gem version is in order so you don't wind up churning through a number of minor versions if this doesn't work?

tknerr commented 9 years ago

Thanks @chrisbaldauf! I built and installed the plugin locally and it seems to work. Will push a 0.7.1 release shortly

tknerr commented 9 years ago

fixed via #51 and released as 0.7.1

chrisbaldauf commented 9 years ago

Thanks @tknerr!