Soms heb je van die dagen dat je van de ene verbazing in de andere valt bij het werkend krijgen van een gevirtualiseerde ontwikkelomgeving. Bij Semantica is de keuze gevallen op Vagrant. In den beginne (Windows 7, Vagrant 1.6, Virtual Box 4.3) liep het ook allemaal wel soepel. Nu gaan we mee in de vaart der volkeren en bestaat de stack uit Windows 10, Vagrant 1.8 en VirtualBox 5.0.
Dit artikel gaat dus niet over de beruchte bril die nu een soort van gehypt wordt, maar over virtualisatie in een desktop omgeving. Ook is er geen garantie dat de voorgestelde oplossingen generiek toepasbaar zijn. Het is vooral bedoeld als geheugensteun voor onszelf waar we in de toekomst mogelijk op kunnen terugvallen.
Als je zoals in mijn geval de Windows 10 vervangt door El Capetan, dan is de realiteit een werkende infrastructuur. Windows 10 gooit klaarblijkelijk wat roet in het eten. Het roet bestaat o.a. uit het niet willen downloaden van de opgegeven vagrantbox.
D:\Develop\ubuntu>vagrant init ubuntu/trusty64
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.
D:\Develop\ubuntu>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0`
`The box 'debian/jessie64' could not be found or`
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
'vagrant login'. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/ubuntu/trusty64"]
Error:
Speurwerk via de meest gebruikte internetzoekmachine leert dat het installeren van de Microsoft Visual C++ Redistributable (uit 2010, want die van 2012 stonden al wel op de machine) ons in ieder geval verder helpt.
Dan treedt er vervolgens een time-out op, waardoor Vagrant de staat van de virtuele machine niet goed kan bepalen.
D:\Develop\ubuntu>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: There was a problem while downloading the metadata for your box
==> default: to check for updates. This is not an error, since it is usually due
==> default: to temporary network problems. This is just a warning. The problem
==> default: encountered was:
==> default:
==> default:
==> default:
==> default: If you want to check for box updates, verify your network connection
==> default: is valid and try again.
==> default: Setting the name of the VM: ubuntu2_default_1457593474553_89798
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
Omdat VirtualBox in de zgn. ‘headless mode’ draait zie je niet echt wat er gebeurt. Door in de VagrantFile
de visuele terugkoppeling (GUI) aan te zetten met:
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
Als de Vagrantfile
is gegenereerd dan volstaat het verwijderen van de commentaartekens bij de juiste regels in de betreffende sectie.
Het eerste dat dan opvalt is de volgende melding:
en de terugkoppeling van Vagrant is als volgt:
D:\Develop\ubuntu>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> default: have version '20160304.0.0'. The latest is version '20160304.0.1'. Run
==> default: `vagrant box update` to update.
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'paused' state. Please verify everything is configured
properly and try again.
If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.
The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.
Om deze melding te onderdrukken is het aanzetten van de hyperthreading c.q. virtualization technology via de BIOS van de PC noodzakelijk. Daarnaast moet je ook Hyper-V bij ‘Windows-onderdelen in- of uitschakelen’ via het configuratiescherm (Configuratiescherm\Programma's\Programma's en onderdelen) instellen. Het meerdere keren opnieuw opstarten van de PC maakt onderdeel uit van de procedure.
Dan ben je er bijna. Zekerheidshalve even een vagrant destroy
uitvoeren, gevolgd door de vagrant up
. In mijn geval resulteerde dat in een time-out.
Doordat de GUI van de virtual box zichtbaar was, kon ik het opstartproces volgen. Onze Vagrant box ubuntu/trusty64 lijkt last te hebben van een netwerk-anomalie.
cloud-init-nonet[4.54]: waiting 10 seconds for network device
cloud-init-nonet[14.57]: waiting 120 seconds for network device
cloud-init-nonet[134.57]: gave up waiting for a network device.
Terug naar de Vagrantfile
dan maar en in dezelfde sectie waar we de GUI hebben aangezet even vertellen dat we de AMD i.p.v. de Intel netwerkadapter willen gebruiken.
config.vm.provider "virtualbox" do |vb|
### Change network card to PCnet-FAST III
# For NAT adapter
vb.customize ["modifyvm", :id, "--nictype1", "Am79C973"]
# For host-only adapter
vb.customize ["modifyvm", :id, "--nictype2", "Am79C973"]
end
Uiteindelijk start de gevraagde Vagrant box op zonder protesteren. Wel de gebruikelijke SSH timeout, dus de puristen onder ons kunnen dat via config.ssh.timeout
optimaliseren.
Nota Bene: vagrant ssh werkt niet standaard onder het Windows OS. Met de output die Vagrant geeft na uitvoering van het commando kan uiteraard gebruikt worden in een SSH client zoals PuTTY. Of je installeert Git met extra (Unix tools) opties, zodat je Vagrant volledig vanaf de commando prompt kan besturen.
Al met al heeft een goed werkende ontwikkelomgeving nogal wat voeten in de aarde. Waarschijnlijk zijn er nog andere hardware-afhankelijkheden waar wij niet tegenaan lopen. Gaat het mixen van 32- en 64-bit omgeving mogelijk niet altijd goed. En zijn er Vagrant boxen die hun eigenaardigheden hebben. Desalnietemin voelt dit artikel als een gedegen geheugensteun waar we op terug kunnen vallen. Mocht je vragen of aanvullingen hebben, vertel het ons!
Verwijzingen: