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

Vagrant 2.0.1: Vagrant Up Hyper-V Error #9256

Closed
ranshac2 opened this issue Dec 11, 2017 · 13 comments
Closed

Vagrant 2.0.1: Vagrant Up Hyper-V Error #9256

ranshac2 opened this issue Dec 11, 2017 · 13 comments

Comments

@ranshac2
Copy link

ranshac2 commented Dec 11, 2017

Vagrant version

Vagrant 2.0.1

Host operating system

Windows 10

Guest operating system

Base

Vagrantfile

$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  # config.vm.box = "base"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

Debug output

https://gist.github.com/ranshac2/eb06b72ffd564727e484dfd44ed06dbd

Expected behavior

A virtual machine should be created using Hyper-V

Actual behavior

Error stating the following:
"The provider 'hyperv' that was requested to back the machine
'default' is reporting that it isn't usable on this system.

The Hyper-V provider requires that Vagrant be run with
administrative privileges. This is a limitation of Hyper-V itself.
Hyper-V requires administrative privileges for management
commands. Please restart your console with administrative
privileges and try again."

Steps to reproduce

  1. Open Powershell or Git BASH with administrator privileges
  2. Run vagrant up --provider hyperv

References

@TonyApuzzo
Copy link
Contributor

The Vagrantfile you specified is invalid. Not sure if this is the actual Vagrantfile you are using or not. If it is exactly this then maybe you are just finding a bug in the error reporting because Vagrant can't create a box when it doesn't know what box to use. (everything in the file is commented out except the wrapper.)

Here is what I see when I use that Vagrantfile on Windows 10 running as Admin with git bash:

tonya@TONY-PC MINGW64 ~
$ cd Documents/Vagrant/github#9256/

tonya@TONY-PC MINGW64 ~/Documents/Vagrant/github#9256
$ vagrant up --provider=hyperv
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* A box must be specified.

@ranshac2
Copy link
Author

I apologize. The Vagrantfile I posted had been altered for troubleshooting. I should have double-checked that it was a proper one before posting.

I get the "The Hyper-V provider requires that Vagrant be run with administrative privileges." error no matter which Vagrantfile I use (I have tried several different ones). I wanted to verify that I was still having issues, even with a fresh Vagrantfile, so I performed a "vagrant init" and then a "vagrant up --provider=hyperv" and I still receive the administrative privileges error.

Here is the Vagrantfile I am using:

$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "base"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

@TonyApuzzo
Copy link
Contributor

TonyApuzzo commented Dec 14, 2017

base doesn't exist either. Try with generic/ubuntu1604.

Aside, I haven't found an official Ubuntu image that has a hyper-v provider.

@ranshac2
Copy link
Author

I tried performing a vagrant up --provider hyperv with the centos/7 box that does support hyper-v as a provider. I am still receiving the error:

$ vagrant box add centos/7 --provider hyperv
==> box: Loading metadata for box 'centos/7'
    box: URL: https://vagrantcloud.com/centos/7
==> box: Adding box 'centos/7' (v1710.01) for provider: hyperv
    box: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1710.01/providers/hyperv.box
    box:
==> box: Successfully added box 'centos/7' (v1710.01) for 'hyperv'!

$ vagrant init centos/7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "centos/7"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end
$ vagrant up --provider hyperv
The provider 'hyperv' that was requested to back the machine
'default' is reporting that it isn't usable on this system. The
reason is shown below:

The Hyper-V provider requires that Vagrant be run with
administrative privileges. This is a limitation of Hyper-V itself.
Hyper-V requires administrative privileges for management
commands. Please restart your console with administrative
privileges and try again.

@TonyApuzzo
Copy link
Contributor

TonyApuzzo commented Dec 14, 2017

I am kind of reaching here but I am wondering if somehow your vagrant process is not getting launched with elevated permissions even though you are running an Admin shell.

Using your admin PowerShell, change directory into your vagrant working directory and run the following command:

PS> Start-Process -Verb RunAs -FilePath vagrant.exe -ArgumentList up

This should open a new window running vagrant, once vagrant completes the 'up' command the new window will close.

This is just a test to see if your vagrant process is running elevated. If you get a UAC prompt then your vagrant wasn't running elevated before and this should fix it. If you don't get a UAC prompt, then vagrant is running as admin but can't figure it out for some reason.

If the previous command works and Vagrant is launched, you should then be able to connect to the running VM with:

PS> Start-Process -Verb RunAs -FilePath vagrant.exe -ArgumentList ssh

If that works, then you can try

PS> Start-Process -Verb RunAs -FilePath powershell.exe

To run the console in the future.

@TonyApuzzo
Copy link
Contributor

(Also I'm just some random dude on the Internet, I have no intimate knowledge of Vagrant or connection to Hashicorp, but am trying to help.)

I haven't been able to reproduce this on my Windows 10 1709 with Hyper-V.

You could also try some of the standard stuff like uninstall / reinstall Vagrant, reboot, disable-re-enable Hyper-V, etc, etc.

@ranshac2
Copy link
Author

Thank you for the help. Unfortunately, none of these suggestions have worked.

@TonyApuzzo
Copy link
Contributor

I'm sorry I'm out of ideas. Hopefully someone else will chime in with suggestions.

@briancain
Copy link
Member

@ranshac2 - have you also confirmed that hyper-v is enabled on your windows host?

@ranshac2
Copy link
Author

Yes, Hyper-V and its components are enabled. I confirmed this issue on 2 separate machines with Hyper-V enabled and running Windows 10. I am able to create and manage VM's through Hyper-V Manager without issue.

@TonyApuzzo
Copy link
Contributor

TonyApuzzo commented Dec 20, 2017

Maybe this has nothing to do with Vagrant. If you use the Get-VM cmdlet in PowerShell it will work in an admin shell and fail in a user shell. If this doesn't work on your machine then something must be restricting your account in a lower-level way than vagrant could deal with. Vagrant uses similar calls to create and manage the VM.

Elevated:

PS> Get-VM

Name                      State   CPUUsage(%) MemoryAssigned(M) Uptime             Status             Vers
                                                                                                      ion
----                      -----   ----------- ----------------- ------             ------             ----
generic-ubuntu1604-hyperv Running 0           2048              1.01:20:10.0130000 Operating normally 8.0
Insight Dev Hyper-V       Paused  0           12800             06:49:48.5370000   Operating normally 8.2

User:

PS> get-vm
get-vm : You do not have the required permission to complete this task. Contact the administrator of the authorization
policy for the computer 'BOU-5520DEMO'.
At line:1 char:1
+ get-vm
+ ~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-VM], VirtualizationException
    + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.GetVM

@chrisroberts
Copy link
Member

Hi there,

It looks like this has been resolved within a previously shipped version of Vagrant so I am now closing this issue. If the original issue was not fully resolved, please reopen this issue or create a new one.

Cheers!

@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants