1

I need to build Vagrantfile. And I need to use Ansible (so, I can't work with Windows).

But my primary OS - Windows 10. I can install Ubuntu on Hyper-V or VirtualBox.

1) I create Hyper-V machine and install Ubuntu on it. But vagrantfile can't use hyper-v as provider and need virtualbox.

2) If I try to start virtual Ubuntu on VirtualBox, I have an error

Failed to open a session for the virtual machine Ubuntu.

AMD-V is not available (VERR_SVM_NO_SVM).

Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

2) If I turn off Hyper-V on Windows, I can launch Ubuntu on VirtualBox.

But when I try vagrant up, I have an error:

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "4e3f95fd-2ad3-423f-a39a-ffd65cfe0d46", "--type", 
"headless"]

Stderr: VBoxManage: error: AMD-V is not available (VERR_SVM_NO_SVM)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component 
ConsoleWrap, interface IConsole

In VirtualBox settings AMD-V/VT-x is enabled screenshot

Is there an opportunity to work with vagrant on virtual Ubuntu? It's so undesirable to change real main system from Windows to Ubuntu.

Thanks for your help!

UPDATE. I can add my virtualbox and BIOS screenshots, maybe it'll be useful.

VirtualBox:

This is my machine with Ubuntu: Screenshot

AMD-V is enabled: Screenshot

BIOS: https://s8.hostingkartinok.com/uploads/images/2017/07/4fe67600624d20d8194edc3d9224db69.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/6f05e15236404042ff929ad10280a1d1.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/23e417ab2fb13191780417030960cb82.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/fbcd47ad170ece6127592a6ca8d7dad5.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/65de25614774edc4f19506c8c10c61fe.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/ca73abc19ee7d82398f0574cf77789b4.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/8a15b5e490b285c41268cd4f6b0930c3.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/9c52e945ad8efc009b772b3e88f5672e.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/3357dd1540a2ea57e308a59ae41cf0af.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/311e96617a120ec3f22f4fe6833d3dc1.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/4963e3b283d1209e4e88a6b14d133dcd.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/628f1138d22dfc8b03a20def857e7967.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/36f8ba9c6a7806914f49b57fceaf7061.jpg https://s8.hostingkartinok.com/uploads/images/2017/07/5a4df9d13773147f691e6ab3b244a547.jpg

At a result, I successfully configured unix subsystem and installed vbox, vagrant and ansible. But when I type vagrant up I see

VirtualBox is complaining that the installation is incomplete. Please run 
VBoxManage --version to see the error message which should contain 
instructions on how to fix this error. 

So, I run VBoxManage --version and have

The character device /dev/vboxdrv does not exist. Please install the 
virtualbox-dkms package and the appropriate headers, most likely linux-
headers-3.4.0+. You will not be able to start VMs until this problem is 
fixed   

And if I try apt-get install virtualbox-dkms it says that the latest version is installed yet.

NaSt
  • 301
  • 1
  • 5
  • 16
  • Note: nested virtualization seems to be supported for Windows, with AMD processor now (Q3 2020): https://stackoverflow.com/a/62250418/6309 – VonC Jun 07 '20 at 19:20

2 Answers2

0

If I understand the question correctly, you would like to use Windows 10 as your host OS, run Ubuntu as a virtual machine on that host OS (using either Hyper-V or VirtualBox), and then run another virtual machine nested within the first virtual machine (using Vagrant/VirtualBox). This is called "nested virtualization."

I do not believe nested virtualization is possible for 64-bit guest OSes on VirtualBox, because VirtualBox does not expose VT-X/AMD-V within the Guest.

For Hyper-V, nested virtualization is supported on Windows 10, but only Hyper-V running in the guest is officially supported. From the documentation: "Virtualization applications other than Hyper-V are not supported in Hyper-V virtual machines, and are likely to fail. This includes any software that requires hardware virtualization extensions."

You could still try running Vagrant and VirtualBox within a VM running on Hyper-V, to see if it works for you.

Looking more broadly at the question, I wonder if you could run the two VMs side-by-side... something like:

  1. Use VirtualBox and Vagrant on Windows 10
  2. Create an Ubuntu VM on VirtualBox to run Ansible on network N
  3. Use Vagrant to create the other VM also on network N

That said, I don't know too much about Ansible, so I'm probably missing something.

Disclosure: I work on the Hyper-V team at Microsoft.

joslack
  • 302
  • 2
  • 4
  • Yes, you are right, I need nested virtualization. And It seems that it's really too difficult. I can run ubuntu on hyper-v machine, but can't run vargant on it, and I can run ubuntu on virtualbox machine, but can't run vargant on it too – NaSt Jul 21 '17 at 10:50
0

In fact, you can work with Windows(sort of). At least, you don't need a full Linux VM for Ansible. Try looking at running Windows Subsystem for Linux in Windows 10 instead, which allows you to use Ansible from there.

You can install Vagrant for Windows which will support Hyper-V provider. Now from Bash on windows you can use both: Linux ansible binary and windows vagrant.exe (which will launch your regular windows console), both from inside that bash shell.

enter image description here

I use Ansible this way very conveniently and I have just tested launching a windows process from bash.

enter image description here

As per above screenshot, any logical drives on your Windows host are accessible via /mnt/drive_letter/ and that is how you can call vagrant. So the workflow for you will be:

  1. Install WSL
  2. Install Ansible inside WSL
  3. Enable Hyper-V component in Windows
  4. Install Vagrant for Windows
  5. Create a playbook that manages the vagrantfile (using Hyper-V provider) and calls "vagrant.exe up"

When ansible-playbook is run, it should spin up the Hyper-V VM as per your vagrantfile. This setup allows you to get any kind of networking connections between your host and vagrant machines, including managing those VMs with your Ansible from WSL, while keeping playbooks close to your Windows heart, and editing them with Notepad++ if you like :)

And here is a site that might help marry Vagrant and Hyper-V with a few examples and detailed steps: Vagrant up on Windows 10 with Hyper-V

Grigory Sergeev
  • 374
  • 4
  • 12
  • It looks rather interesting, I'll try this right now – NaSt Jul 21 '17 at 11:04
  • So, I successfully configured subsystem and installed vbox, vagrant and ansible. But when I type `vagrant up` I see `VirtualBox is complaining that the installation is incomplete. Please run `VBoxManage --version` to see the error message which should contain instructions on how to fix this error.` So, I run `VBoxManage --version` and have `The character device /dev/vboxdrv does not exist. Please install the virtualbox-dkms package and the appropriate headers, most likely linux-headers-3.4.0+. You will not be able to start VMs until this problem is fixed.` – NaSt Jul 21 '17 at 12:55
  • And if I try `apt-get install virtualbox-dkms` it says that the latest version is installed yet – NaSt Jul 21 '17 at 12:57