Live data from Hacker News

Vagrant core no longer tied to VirtualBox

github.com

41–50 of 61 posts

Re: Vagrant core no longer tied to VirtualBox

#41

> Showing 122 changed files with 4,156 additions and 2,915 deletions. Wow, that's a lot of code for a tool which is doing little more than creating, starting, stopping, deleting, and zipping-up VMs. Looking at this diff, all I can say is: Holy Java-ish Ruby, Batman! Most of these classes contain two non-helper methods: init and call. That's not a class; that's a function! I'm reminded of this talk, titled "Stop Writi…

Vagrant author here. Allow me to address both of your points.

First, the "Java-ish" Ruby: I am using the middleware pattern. The classes are used to build up complex sequences of actions[1]. They are reusable and very easily testable. Why classes? Why not modules with functions? It actually started out as modules with functions, but middleware was so _painfully_ the RIGHT way to do things, I can't imagine doing it any other way. Instead of explaining it all, I guide you to this talk I gave on the pattern: http://confreaks.com/videos/961-mwrc2012-rack-middleware-as-...

Next, on Vagrant being "overkill." Write a shell script that does the following: Import a virtual machine, setup host only networking, setup shared folders, boots the machine, runs a provisioner within the machine. Wow that is simple. Oh, wait, I need that script to work on Mac, Linux, and Windows. Oh, VirtualBox has some bugs so can you work around that?[2] Also, host only networking requires some guest OS specific setup (Ubuntu different from Fedora different from FreeBSD etc.), so you have to handle that. Right, and it'd be nice if the script didn't setup networking that collided with other machines on the network, so please write in checks that ports and IPs don't collide. Maybe the script should also verify that Guest Additions are properly installed. AND shared folder performance in VirtualBox sucks, so can you modify that script to use NFS? But only on non-Windows, because Windows doesn't support NFS. Did I mention that NFS requires specialized configuration depending on the host OS AND guest OS? So if you're running Mac + Ubuntu its totally different from Linux + FreeBSD. Have fun!

Now, make all of that REUSABLE and EXTENSIBLE, while adding in some other features (other types of networking, host name setting, and so on).

Yeah, I'd say Vagrant's 3000 line of code count is pretty spot on, and pretty good.

[1]: https://github.com/mitchellh/vagrant/blob/391dc392675c73518e...

[2]: https://github.com/mitchellh/vagrant/blob/391dc392675c73518e...

Re: Vagrant core no longer tied to VirtualBox

#42

> Showing 122 changed files with 4,156 additions and 2,915 deletions. Wow, that's a lot of code for a tool which is doing little more than creating, starting, stopping, deleting, and zipping-up VMs. Looking at this diff, all I can say is: Holy Java-ish Ruby, Batman! Most of these classes contain two non-helper methods: init and call. That's not a class; that's a function! I'm reminded of this talk, titled "Stop Writi…

See the recent thread on HN, one writes a useful tool, gives it away, top voted comment on HN is a sniping comment about code style.

But now it's followed by an awesome reply by the author where I actually learned something!

Re: Vagrant core no longer tied to VirtualBox

#43

> Showing 122 changed files with 4,156 additions and 2,915 deletions. Wow, that's a lot of code for a tool which is doing little more than creating, starting, stopping, deleting, and zipping-up VMs. Looking at this diff, all I can say is: Holy Java-ish Ruby, Batman! Most of these classes contain two non-helper methods: init and call. That's not a class; that's a function! I'm reminded of this talk, titled "Stop Writi…

Yes, the project seems to have around 380 files. I'd be interested to hear from the author if he's reading this thread why the codebase is at this size. Perhaps VirtualBox quirks necessitate a large part of it?

Vagrant author here.

Files in lib/ (core): 71

Files in plugin/: 142

Total: 213.

Still a lot of files but not 380, just wanted to point that out. Each individual file is actually rather small. There are only a few larger files in there (Vagrant::Environment actually perhaps being the only one).

"Why the codebase is at this size." Well, Vagrant started very small, but in the 3 years of its existence, it has gained a lot of what I've previously heard called as "code wisdom:"

* Generic host support since some tasks are host-specific. For example, setting up NFS on Mac OS X differs from Ubuntu which differs from FreeBSD. Vagrant knows this.

* Generic guest support. Setting up a variety of things is guest OS specific, so again, Vagrant knows how to configure networks, mount folders, etc. on a variety of different guest operating systems.

* VirtualBox bugs. Vagrant has quite a bit of code to work around VirtualBox bugs.

* Networking is hard. Vagrant does quite a lot with networking to ensure your networking works as expected. It also does things like port collision detection to verify that any ports you choose won't collide with any other VMs as well as making a best effort to check if that port is open, and erroring in that case as well.

* Plugin interface. Almost every part of Vagrant at this point in git master is customizable. This isn't overkill, this was built out of seeing actual human need for this. This lowers the number of features I need in core and actually fights being overkill, because more things can be built with plugins.

* Communication abstraction. Linux and POSIX-like guests with SSH is great, but what happens when you want to run Windows guests? SSH CAN work but isn't ideal. For this reason, Vagrant is started to abstract out communication so that Windows can use things like WinRM, completely transparently. Also, if you use something like VMWare, it uses the VMWare guest communication API, which is blazingly faster than SSH. Again, this is all transparent to plugin developers, provisioners, etc. It "just works."

It does much more, but I think you get the idea.

Building something that "just works" comes at a cost. And that cost is usually complexity. Can you build a very basic tool to control VirtualBox virtual machines in a small shell script? You betcha! Vagrant started this way. Can you make that reusable? Yeah, but prepare to add some complexity. Then make it run on every major OS and support some nifty features and you got yourself a big project.

I hope that helps!

Re: Vagrant core no longer tied to VirtualBox

#44
post #34

Earlier quoted context omitted.

That you don't like the design and coding style strikes me as a poor reason not to use a system. It's utterly orthogonal to whether that system solves your problem. I am prepared to bet $250 -- your choice of USD or AUD -- that within 1 year your shell script will have grown beyond seven commands.

I've been using my own bash scripts for a few years to manage local VMs with KVM for dev and I have exactly 6 commands in 249 lines (excluding blank and comments) and never needed more: image, create, start, stop, delete, list. Where can I collect my $250 USD?

Cute, but that wasn't the bet. They were referring to seven bash commands, i.e. "lines". So you lose by 242 commands.

Re: Vagrant core no longer tied to VirtualBox

#45

I'm not sure what are the benefits of supporting many VM providers for a tool that is meant for development (as far as I understand at least). Isn't VirtualBox sufficient? It is open source and runs on Linux, OS X and MS Windows. Perhaps I am missing some core idea. Then there is veewee[1] which started life as a Vagrant plugin but as of version 0.3.0 it can be used standalone and one can ssh to the boxes using it, j…

The power in Vagrant is not the technology, it is actually the workflow. Vagrant is now in use by thousands of companies worldwide (some of the bigger ones you can see on vagrantup.com), and they consistently tell me that the power in Vagrant is that every developer, designer, etc now knows they can get some code and just type `vagrant up` and be working within a few minutes. When they're done? `vagrant destroy`. Small example, but Vagrant provides a consistent workflow.

There is a benefit to having this workflow on other systems.

First, VirtualBox has major problems. VirtualBox routinely kernel panics on a variety of operating systems, even leading to the point that there is a commit to the linux kernel that ignores crash reports from VirtualBox.

Second, the whole goal of Vagrant is to have development mimic production as closely as possible, and to make development fun. Some companies that use Vagrant can't mimic production very well on a single laptop, so they have a private cloud. They still want to use Vagrant -- because of the workflow! -- and this caters directly to them.

Also, for people on Linux, I know its not full virtualization, but some problems can be solved with simple LXC. Those people write scripts around LXC because LXC is pretty simple, but it would be pretty nice to get the benefits of Vagrant there, too. That is coming! Vagrant will support LXC.

Libvirt doesn't compare to Vagrant at all. If anything, they compliment each other.

And veewee-like functionality will make its way into Vagrant core very soon.

Re: Vagrant core no longer tied to VirtualBox

#46
post #32

Earlier quoted context omitted.

LXC is great but does have its limitations. We are currently building a vagrant like solution and GUI for LXC/Vagrant/vSphere/ESXi/Xen/AWS etc which will launch in beta in the next couple of months - sign up at http://10xlabs.net if you are interested in following progress

There seems to be no other way to communicate with you or 10xlabs, so excuse me for cluttering this thread. You have an error on the sign up page - 'lounch' should be 'launch'.

Thanks - we are fixing it now - you can contact us at info@10xlabs.net or on twitter @10xlabs

Re: Vagrant core no longer tied to VirtualBox

#47
post #3

Reimplementing libvirt, badly ...

Vagrant author here.

This is incorrect. I am not trying to reimplement libvirt at all. If anything, I'm providing the infrastructure to use libvirt WITH Vagrant. Actually, surprise! I'm working with RedHat to do JUST THIS.

I applaud the libvirt project for everything they've done. We've had our difference, but I have no intention of competing with that project. The power in Vagrant is the workflow of Vagrant, not Vagrant's ability to abstract away the hypervisor (and I certainly don't want to play that game).

The power in Vagrant is the workflow, and that is the game that I'm playing.

Re: Vagrant core no longer tied to VirtualBox

#48

This is exciting news. I know one fellow who built a large private cloud for his organisation (about two racks of topline gear) so that they could simulate an architecture of several dozen servers and thousands of complex, concurrent transations. What's it built on? VMWare. He was not totally amused when I sent him a link to Vagrant. (I understand VMWare have similar fleet-orchestration tools, but not development-ori…

Thanks! Vagrant will soon be able to control development cycles around private clouds just like this. This is exactly the use case I am building for. Let your friend know!

Re: Vagrant core no longer tied to VirtualBox

#49

> Showing 122 changed files with 4,156 additions and 2,915 deletions. Wow, that's a lot of code for a tool which is doing little more than creating, starting, stopping, deleting, and zipping-up VMs. Looking at this diff, all I can say is: Holy Java-ish Ruby, Batman! Most of these classes contain two non-helper methods: init and call. That's not a class; that's a function! I'm reminded of this talk, titled "Stop Writi…

Vagrant author here. Allow me to address both of your points. First, the "Java-ish" Ruby: I am using the middleware pattern. The classes are used to build up complex sequences of actions[1]. They are reusable and very easily testable. Why classes? Why not modules with functions? It actually started out as modules with functions, but middleware was so _painfully_ the RIGHT way to do things, I can't imagine doing it an…

It is worth searching through all these comments and reading what Mitchell (mitchellh) has to say. It's been very informative getting the author's perspective on every important issue brought up in this thread.

Re: Vagrant core no longer tied to VirtualBox

#50
post #3

Reimplementing libvirt, badly ...

Vagrant author here. This is incorrect. I am not trying to reimplement libvirt at all. If anything, I'm providing the infrastructure to use libvirt WITH Vagrant. Actually, surprise! I'm working with RedHat to do JUST THIS. I applaud the libvirt project for everything they've done. We've had our difference, but I have no intention of competing with that project. The power in Vagrant is the workflow of Vagrant, not Vag…

Well, I take it back. This is great news.
Post reply on HN