Why my Vagrantfile is calling Hyper-V hypervisor even disabled at Windows?

Posted on

QUESTION :

I did an upgrade of Windows 10 Professional to the lastest build (brazilian portuguese):

Microsoft Windows [versão 10.0.18363.592]

After this when I ran my Vagrantfile even calling the config provider with Virtualbox and disabling Hyper-V resources show me this message:

C:UsersMarlonDownloadspipeline (master -> origin)
λ vagrant up                                                 <-using cmder (
Bringing machine 'centos7' up with 'hyperv' provider...
Bringing machine 'debian10' up with 'hyperv' provider...
==> centos7: Verifying Hyper-V is enabled...
The Hyper-V cmdlets for PowerShell are not available! Vagrant
requires these to control Hyper-V. Please enable them in the
"Windows Features" control panel and try again.

Hyper-V is disabled if you see at powershell:

PS C:UsersMarlon> # Check if Hyper-V is already enabled.
PS C:UsersMarlon> if($hyperv.State -eq "Enabled") {
>>     Write-Host "Hyper-V is already enabled."
>> } else {
>>     Write-Host "Hyper-V is disabled."
>> }
Hyper-V is disabled.

Tried to just add Windows module cmdlet looking this site:

https://www.altaro.com/hyper-v/install-hyper-v-powershell-module/

enter image description here

Look when I enable just Windows Powershell module for Hyper-V:

C:UsersMarlonDownloadspipeline (master -> origin)
λ vagrant up
Bringing machine 'centos7' up with 'hyperv' provider...
Bringing machine 'debian10' up with 'hyperv' provider...
==> centos7: Verifying Hyper-V is enabled...
==> centos7: Verifying Hyper-V is accessible...
==> centos7: Importing a Hyper-V instance
    centos7: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm.ps1
Error:

O Hyper-V não foi instalado no computador 'DESKTOP-GQN4SVI'.

Look at first lines of my Vagrantfile and see that config provider settings have a line for VirtuaBox.

Vagrant.configure("2") do |config|
  config.vm.provider "virtualbox" do |vb|
     vb.gui = false
     vb.memory = "4096"
     vb.cpus = "4"
  end

  config.vm.define "centos7" do |centos7|
      centos7.vm.box = "centos/7"
      centos7.vm.hostname = "centos-vm"
      centos7.vm.network "public_network", ip: "192.168.0.105"
      centos7.vm.network "forwarded_port", guest: 8080, host: 80
      centos7.vm.provision "shell", run: "always", inline: <<-SHELL
         sudo yum update
         sudo yum -y install wget ntpdate net-tools nano firewalld jenkins apache telnet
         sudo route add default gw 192.168.0.1

         # Install java
         sudo yum -y install epel-release
         sudo yum -y java-1.8.0-openjdk.x86_64
         java -version

         #install ansible
         sudo yum -y install ansible

         sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
         sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
         sudo yum -y install jenkins
         sudo systemctl daemon-reload
         sudo systemctl status jenkins
         sudo systemctl start jenkins
         sudo systemctl status jenkins
         sudo systemctl enable --now jenkins

         # Install docker
         curl -fsSL https://get.docker.com/ | sh
         sudo usermod -aG docker $USER
         sudo systemctl start docker
         sudo systemctl status docker
         sudo systemctl enable docker
         sudo ps -ef | grep dockerd
      SHELL
  end

  config.vm.define "debian10" do |debian10|
      debian10.vm.box = "debian/buster64"
      debian10.vm.hostname = "debian-vm"
      debian10.vm.network "public_network", ip: "192.168.0.106"
      debian10.vm.provision "shell", run: "always", inline: <<-SHELL

         # isntall python with venv
         sudo apt update
         sudo apt -y upgrade
         python3 -V
         sudo apt install -y python3-pip
         sudo apt install build-essential libssl-dev libffi-dev python3-dev
         sudo apt install -y python3-venv
         mkdir environments
         cd environments
         python3.7 -m venv my_env
         ls my_env
         source my_env/bin/activate

         sudo apt install wget ntpdate net-tools nano default-jdk -y
         sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common telnet -y
         sudo route add default gw 192.168.0.1
      SHELL
  end
end

I don’t know to figure out because I until saw the BIOS to see if Virtualization resource was disabled and is not.

I just would like to run vagrant up and call VirtualBox provider without callinng Hyper-V with no error messages…

Update 1st comment:

PS C:WINDOWSsystem32> Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All


Path          :
Online        : True
RestartNeeded : False

ANSWER :

Installed Vagrant 2.2.7 and is working fine now!

Vagrant version:

C:UsersMarlonDownloadspipeline (master -> origin)
λ rm -fr .vagrant

C:UsersMarlonDownloadspipeline (master -> origin)
λ vagrant --version
Vagrant 2.2.7

Virtualbox version:

C:Program FilesOracleVirtualBox
λ VBoxManage.exe --version
6.1.2r135662

https://github.com/hashicorp/vagrant/blob/v2.2.7/CHANGELOG.md

Leave a Reply

Your email address will not be published. Required fields are marked *