Using Vagrant on Windows was always a hassle for me. Followers of my YouTube Channel, PanadeEdu, may remember my small bash script for controlling Vagrant. Some time ago, I built a small tool in C# that offers me a simple to use GUI for handling my Vagrant projects. I never mentioned this Tool on my Channel, so maybe a post here will fill the need if someone is interested.
I like Windows, I like GUI’s for stuff I use on a daily basis. Vagrant is a tool, I run at least once a day. I like my Linux command line, but I dislike navigating and using the powershell in Windows. There are some tools out there that offer Vagrant management with a GUI.
The best approach so far is “Vagrant Manager“, since it delivers on features and usability. You can manage all your Vagrant systems from a tray icon, which is pretty neat. However I disliked the bad development of the Windows version. The Project seems to be discontinued for Windows and problems don’t get addressed. It seems to be designed for VirtualBox and I think it works very well with that. However I use VMWare and in my VirtualBox times I made use of the special Configurations, to allow symlinking with Windows shared folders. Both cases require administrative rights on Windows, which this tool doesn’t deliver on default.
So I decided to build my own tool. I tried different approaches but C# was the most straight forward, for my problem.
Well, the tool is designed for Windows and tested on Windows 7, 8, 8.1 and 10.
It requires administrative rights. (you can check the source code here, if you feel bad with that).
You need the Tool itself, available here: VagrantGui
You require tolerance to my bad design skills. 😉
The tool is a simple executable file, simply put it in the same directory as your Vagrantfile. You can also put the VagrantGui.exe anywhere you want, but I usually create a shortcut from this file to my Desktop and name it after my project.
VagrantGui detects a Vagrantfile in the directory it’s currently in, per default. You can also tell him, where to find your Vagrantfile afterwards.
How to use it
When launching VagrantGui, it presents you the interface. There is not much to it and it might now be the most beautiful thing you have ever seen, bit it does the job. Depending on your Windows settings, it may ask you for administrative rights. You can accept them, or keep a look at the source if you feel curious.
Lets discuss this beauty in detail, in small steps.
The big blue thing, obviously is for the output, Vagrant generates.
It is enriched with the information which directory the “vagrant up” is executed in, as well as the command output.
The control bar/panel executes the most basic Vagrant commands.
From left to right: vagrant reload, vagrant up, vagrant suspend, vagrant halt.
The “Custom Command” field lets you basically execute every Windows CMD command in this directory.
I implemented it, to allow the shortcut execution of any command, if needed.
You will find this useful, when using debugging or provisioning Parameters.
The “Vagrant Folder” field, lets you choose any target directory.
Any Vagrant command executed, will be executed in the directory this executable is in,
or in the Directory given by this setting.
The “Destroy VM” button, executes the command “vagrant destroy”.
To prevent data loss, it will ask for a confirmation with a prompt.
Benefits and Flaws
This started out as small side Project, since I never built a GUI App like that before.
The benefit of this App: it is very lightweight and self explaining.Since it only executes Commands and passes them to the CMD, it is unlikely to break anytime soon.
But there are also some flaws known.
The first is the enforcing of administrative rights. Since this is not always required, I should have made this optional.
Another problem shows up, when executing a vagrant command that takes unusually long.
You cant abort commands executed with this tool, so your only option is to kill the underlying ruby process.
I usually work around this problem, by using the powershell to initially setup or debug Vagrant projects.
Once they are running, I use this tool to start and stop my Machines. Since I have this GUI then sitting in the background, I also always remember to stop my VM. The awareness of the VM being running is worth much to me.
Even if this tool looks adventurous and silly, it does what it was meant to do very well.