Making Vagrant play nicely with Hyper-V; that can be a bit of a ballache
Well, my personal laptop has been upgraded to Windows 10 Anniversary; it’s a dual SSD + HD affair, an Asus NX501-JW which hasn’t been affected by the other “SSD+HD” bricking issues that have been in the tech news. Anyway, either I, or Microsoft during the upgrade, uninstalled Virtualbox, which I had been using to run an HPCC Systems environment amongst other things. In the end, the chance to run Docker natively, and Linux shell natively via Hyper-V persuaded me that I should try and get Vagrant to play nice to Hyper-V; this then is an afternoon of fun and games.
VirtualBox has long been the default provider for Vagrant and if you search for boxes on Atlas, they’re the ones that are most popular. Hyper-V is supported, but there aren’t as many boxes around. This then is a distilled how-to for getting a box up and running with NAT on Hyper-V. For brevity, I’ve just distilled the raw commands with no explanation as to why I’m doing things as I’ve done them; they just worked for me.
Create a NAT switch
Once you have the Hyper-V role enabled; then you need to add a virtual switch, so use powershell to do that (run as Administrator naturally) rather than the Hyper-V manager UI.
Our production machines are all CentOS or variants of, so I like to stick with what I know. There aren’t that many CentOS 7 boxes available, so I used serveit/centos-7 which works well enough.
Once you run vagrant up, it’s up, and you can vagrant ssh to it; but it may well have defaulted to IPV6; which probably isn’t all the useful for you.
Fiddling the network card.
So, now we need to fix up the network card (easy enough to do) with a fixed IP Address.
After that, a vagrant halt followed by a vagrant up will fix up the IP addresses nicely.
Huh, can’t mount my shared folders
If you’re using the serveit/centos-7 image then it may fail to mount whatever shared folders you’ve specified with some error or other. To cut a long story short, because it’s a minimal image, it doesn’t come with cifs-utils; Get that via yum (because you have NAT right) and you’ll be able to mount whatever shares you need in your vagrant file, and voila you have a provisioned CentOS-7 machine.