Grenade Sandwich Explosive thoughts on code, technology and life by Steven Merrill

Blog Posts

  • OmniOS and Vagrant

    Posted on 23 Sep 2012. Filed under .

    <3 ZFS

    I've recently gotten religion about ZFS, and as a result, I've been looking hard at the various systems that offer you the ability to use ZFS and other amazing tools from the Solaris lineage (now being developed freely under the Illumos moniker after Oracle's unceremonious murder of OpenSolaris.)

    My data's backed up on an 8 TB FreeNAS, but there's also an amazing trend of Illumos-based distributions on offer that offer KVM virtualization, which was ported to Illumos by Joyent for their SmartOS distribution. Theo Schlossnagle recently gave a talk at the NYC DevOps meetup about their Illumos-based OmniOS distribution. OmniOS is a bit more than a JeOS - it aims to provide just enough packaged software to let you build the Illumos kernel and several other important tools like tmux and screen, and then get out of your way. Like SmartOS, it provides both lightweight zones-based virtualization and KVM for full hardware virtualization, but OmniOS is designed to be permanently installed on a machine, as opposed to SmartOS's focus on USB or PXE booting and ephemeral global zone configuration.

    OmniTI also makes a larger set of packages that their Managed Services team uses at http://pkg.omniti.com/omniti-ms/en/index.shtml.

    KVM? Not today.

    But at the end of the day, Vagrant is still the platform I use to run applications with the correct operating system, software versions, and production configurations, so I need Vagrant (and thus VirtualBox) to run on my workstation.

    I am happy to report that I was able to get VirtualBox and Vagrant to the point that they could boot a box, and use host-only networking despite being a complete UNIX and Solaris noob. (Thanks to Mitchell and the whole Vagrant community for an awesome piece of software.)

    Get it installed

    Here's the roundup on how to get it all up and running. All commands were run as root in the global zone.

    Install a few utility packages. This is not strictly necessary, but it helps.

    $ pkg install terminal/tmux
    $ pkg install developer/versioning/git
    

    Set up a static IP as pointed out in http://omnios.omniti.com/wiki.php/GeneralAdministration. In my case, it was 192.168.0.160.

    You will also need to set up your gateway as a DNS resolver. To do so on UNIX, add at least a search and nameserver to /etc/resolv.conf. I am using the following:

    search nyc.rr.com
    nameserver 192.168.0.1
    

    Set up NSS to read resolv.conf.

    $ cp /etc/nsswitch.{dns,conf}
    

    Add the OmniTI managed services package repo to make getting a few things easier.

    $ pkg set-publisher -g http://pkg.omniti.com/omniti-ms/ ms.omniti.com
    

    Rebuild the package index

    $ pkg rebuild-index
    

    Install Ruby and gcc 4.6 to be able to build gem extensions. Also ensure libffi is there since Vagrant needs the ffi gem.

    $ pkg install omniti/runtime/ruby-19
    $ pkg install developer/gcc46
    $ pkg install library/libffi
    

    At this point you should be ready to install the Vagrant gem. The Ruby 1.9 executables like gem and irb get put into /opt/omni/bin/.

    $ /opt/omni/bin/gem install vagrant
    

    Run a quick vagrant help to ensure that everything's hooked up properly.

    $ /opt/omni/lib/ruby/gems/1.9.1/gems/vagrant-1.0.5/bin/vagrant help
    

    Next up we need to install VirtualBox. I saw errors related to the Crossbow-based networking kernel module while trying to install a variety of versions of VirtualBox, so we can force the older stream-based VirtualBox networking driver to install.

    $ touch /etc/vboxinst_vboxflt
    

    With that in place, download and extract the VirtualBox 4.2.0 release for Solaris guests.

    $ wget http://download.virtualbox.org/virtualbox/4.2.0/VirtualBox-4.2.0-80737-SunOS.tar.gz
    $ tar xzf VirtualBox-4.2.0-80737-SunOS.tar.gz
    

    Next up, install the package.

    $ pkgadd -d VirtualBox-4.2.0-SunOS-r80737.pkg
    

    At this point you should be ready to download a Vagrantfile and go. I've made a sample one that you can try with.

    $ curl https://raw.github.com/gist/0509301bb7c62e523b49/87e75688b45631ca9492123c5f160d2311e84604/gistfile1.rb > Vagrantfile
    $ /opt/omni/lib/ruby/gems/1.9.1/gems/vagrant-1.0.5/bin/vagrant up
    $ /opt/omni/lib/ruby/gems/1.9.1/gems/vagrant-1.0.5/bin/vagrant ssh
    

    And with that, the box should download and the second command should have you logged in as the vagrant user on your very own Ubuntu 12.04 LTS VM.

    Host-only networking

    There is one peculiarity to VirtualBox on OmniOS (which, granted, might be VirtualBox on Solaris/Illumos - I have no idea.) Windows, Mac, and Linux hosts all have the ability to create a host-only interface with the VBoxManage hostonlyif create command-line option. That option does not exist in the Solaris version of VirtualBox. In my experience from this weekend, VirtualBox will create you a vboxnet0 interface which can be used as a host-only network. If you do wish to use host-only networking with your VM, you will have to set it up before you run vagrant up.

    I usually run my host-only interfaces inside of 172.16.0.0/12. For the sake of argument, let's say we want to give this VM a host-only address of 172.31.31.31. (The sample Vagrantfile has this configuration commented out.) By setting the IP address of vboxnet0 to 172.31.31.1, vagrant will not try to run VBoxManage hostonlyif create, and host-only networking will also work. The VBoxManage command to do so is as follows:

    $ VBoxManage hostonlyif ipconfig vboxnet0 -ip 172.31.31.1
    

    Not exhaustive

    I haven't tried out a full client setup though Vagrant on OmniOS yet, and I think I'll still be booting my workstation into Fedora 17 for the next week to run KVM and/or VirtualBox VMs. Here are the remaining things that I'd need to nail down before I could use OmniOS and Vagrant together:

    • There's no Solaris host class in Vagrant, so the ability to export files (like your codebase) from the host to the guest via NFS won't work yet. That said, since ZFS has deep hooks into NFS, this might be super simple to implement assuming that you boot from ZFS.
    • The host-only networking bit is strange, and I don't know enough about OmniOS or Crossbow to say what's going on.
    • I haven't tested out applying Puppet or Chef configuration to the guest. OmniTI makes a Chef package available in the managed services repository, and the Puppet and Facter gems install without issue, so this should be rather painless.
    • VirtualBox should probably be run in its own zone.

    » Continue reading this article.

  • Bonjour, mes amis!

    Posted on 16 Jan 2012. Filed under .

    Apple's Bonjour service just saved me a lot of hassle.

    I took a little time this MLK Day to get some old electronics ready for sale. One of the machines I decided to clean up was an old Mac Pro. I've recently replaced it with a Mac mini that positively sips power: 10 - 12 watts at idle instead of the consistent 120 watts that my old Mac Pro would draw. (I'll write more on cutting my setup's power consumption in a later blog post.)

    I hooked my Mac Pro up to my router with an Ethernet cable but didn't want to get out a keyboard, mouse, and monitor to do a final set of backups and deauthorize some software. Normally this wouldn't be a problem since the old Mac Pro was set configured to start Apple Remote Desktop at boot.

    I forgot that since switching to the Mac Pro, I had reassigned the Mac Pro's IP address (192.168.0.150) to the Mac mini. The Mac Pro booted, but could not get a proper IP address since the address it was configured to use was in use.

    I was about to break out my keyboard, mouse, and monitor when I thought I'd give Bonjour a try.

    » Continue reading this article.

  • Dude, Where's My Bot?

    Posted on 05 Oct 2011. Filed under .

    Say what you will about node.js, but it is certainly an easy way to build IRC bots with the Jerk library.

    The PHP-based bot that runs in the Treehouse Agency IRC channels knows to respond to "Sweet!" with "Dude!" and vice versa. Brian McMurray said that he'd like to someday write a quick-and-dirty bot that would put our other bot into an infinite loop.

    I accepted that challenge, and 10 minutes later, the bot was done.

    The code is an example of how to build a bot that accepts environmental variables for configuration and otherwise does a pretty silly task.

    » Continue reading this article.

  • A PSA: Lion and .local Domain Names

    Posted on 08 Sep 2011. Filed under .

    Do you enjoy your hair? Would you prefer not to pull it out while waiting for your local Apache server on Mac OS X to deliver a page to you?

    If you use Mac OS X Lion and have development sites set up at .local addresses, you should immediately move them to any other fake TLD. The .local address space is resolved for Bonjour and as a result any request to a .local name will not hit /etc/hosts first, but will search for Bonjour hosts first.

    I found this Stack Exchange question on the subject tonight after getting frustrated with curl seemingly hanging for several seconds on each request.

    Instead, I switched all of my local dev sites from $DOMAIN.local to $DOMAIN.dev. The results are staggering.

    » Continue reading this article.

  • CentOS 6 and VirtualBox (VBoxHeadless CPU Usage Fix)

    Posted on 29 Aug 2011. Filed under .

    TL;DR: Add "noapic" to your kernel line if your VBoxHeadless process uses far too much CPU.

    I've been working on making space-efficient CentOS 5.6 and 6 images for VirtualBox recently. I'm building the images as part of a pilot program to start using the Vagrant gem to allow our developers to test the Drupal code they write on the real production OS before pushing it to the dev server. (I'm also learning Puppet, both for this project and as a way to more easily re-use tested configurations as we launch new sites.)

    The CentOS 5.6 images I made worked like a charm, but ran into a problem wherein the VBoxHeadless process that hosted my CentOS 6 image would always use 25% CPU on my MacBook Air (one full core) despite the guest OS showing between 98% and 100% idle.

    » Continue reading this article.

  • What Are You Eating?

    Posted on 17 Aug 2011. Filed under .

    Biking to the George Washington Bridge was just not going to work on the day before Memorial Day. The crowds were too packed in the park on the way up to the GW Bridge, and so I turned around and decided to do a nice brisk ride along the Hudson River Greenway and through Central Park.

    I'm a big guy. I'm currently around 280 pounds, and yet when I ride I tend to be faster than most cyclists on the path by quite a bit. On this particular evening, I pedaled hard up the uphill entry ramp to the Greenway and saw in my rear-view mirror that I had another cyclist who was following pretty closely behind me.

    I shot down the Greenway, passing cyclists and genuinely enjoying the cool breeze and the fresh smell of the Hudson River. My unknown cycling companion was generally only one or two bike lengths behind me. As much as I love to bike, I do not take it to the level that some folks in New York City do. I don't have a set of "real" biking shorts or a real biking jersey, nor do I have a super-expensive road bike. My anonymous companion, however, did appear to have all these trappings: a bike that looked like it could have been made of carbon fiber and a set of biking shorts and a jersey from some race or event.

    » Continue reading this article.

  • Be More Awesome (Please!) : A Tale of Two Browsers

    Posted on 22 Jun 2011. Filed under .

    When Firefox 4 came out, I switched to it. I was mainly impressed by its speed (relative to the stable version of Chrome at the time) and the efficacy of Firefox Sync.

    Several weeks later, I abandoned it for the stable build of Chrome. There were several things that contributed to its downfall in my eyes. Chief among them was its effect on my battery life on my MacBook Pro. Despite being nearly as fast as Chrome in user-perceived speed, Firefox generally used more CPU. There was also a very annoying bug that resulted in a ton of modal popups.

    About a month back, I switched from the Chrome stable released to the Chrome dev channel and I've been in general very pleased. There's one feature that has been slowly gnawing away at my sanity, however, and it's gotten serious enough that I'm switching back to Firefox 5 to see if my complaints about Firefox 4 have been addressed.

    » Continue reading this article.

  • Fuddled API, Verbose Workaround

    Posted on 09 Jan 2010. Filed under .

    I've started writing some Scala applications (including one atop the Lift web framework) to access Unfuddle's API recently. I've mainly been building daily burndown reports for my team at Treehouse Agency. I've run into a few issues with API methods not working as advertised, and Unfuddle's been pretty good about fixing most of them.

    The problem I've been experiencing as of January 5th is that Unfuddle has subtly broken authentication for client libraries that (wisely) wait for a 401 error with an accompanying WWW-Authenticate: Basic header before sending credentials. (Namely, Unfuddle's API stopped sending a WWW-Authenticate header altogether.) If need be, you can force most HTTP client libraries to send authentication on every request in one way or another, and that's what I had to do tonight with the excellent Databinder Dispatch library.

    » Continue reading this article.

  • Python to Scala 2.7: Check Your Spelling

    Posted on 27 Nov 2009. Filed under .

    Last time out, I talked about the benefits of Scala, and why I'm looking at Scala and Lift.

    In that spirit, I spent some time last weekend converting Peter Norvig's simple Python spell-checker to Scala. I didn't do this conversion alone; I got some great answers from Daniel Sobral, Daniel Spiewak and finally David Winslow on Stack Overflow. David provided the answer I needed for the best way to implement the matching function in Scala 2.7.

    » Continue reading this article.

  • Scala, Lift, and the Future

    Posted on 26 Nov 2009. Filed under .

    I've been spending a decent amount of my after-hours time investigating a combination that I think will be part of the future of web programming: the Scala programming language, and the Lift web framework on top of it.

    » Continue reading this article.

  • Everything Old is New Again

    Posted on 12 Oct 2009. Filed under .

    It's time for my quarterly blogging drive, and to start, here's some information on my ever-increasing need to try out cool web technologies.

    » Continue reading this article.

  • Need for Speed

    Posted on 27 Jun 2009. Filed under .

    I've been doing some pretty exciting things recently with website performance. I always disliked doing IT work in the past, but the challenge of setting a server up to be able to withstand crushing traffic is now quite intriguing to me.

    » Continue reading this article.

  • Fritz Wunderlich - O Wie Angstlich

    Posted on 30 Mar 2009. Filed under .

    Sorry, it looks as though Fritz Wunderlich - O Wie Angstlich was too pithy for a preview.

    Won't you please read the whole thing?

  • Why I Hate Drupal: Friday the 13th Edition

    Posted on 13 Mar 2009. Filed under .

    Now that I'm back from my month-long blog hiatus and from DrupalCon DC 2009, I thought I'd throw up a little post in the same vein as walkah's brilliant Why I Hate Drupal talk.

    » Continue reading this article.

  • An MTA Train at 96th

    Posted on 31 Jan 2009. Filed under .

    Sorry, it looks as though An MTA Train at 96th was too pithy for a preview.

    Won't you please read the whole thing?

  • Tree House Flips Out

    Posted on 24 Jan 2009. Filed under .

    Sorry, it looks as though Tree House Flips Out was too pithy for a preview.

    Won't you please read the whole thing?

  • Back to Blogging

    Posted on 24 Jan 2009. Filed under .

    Welcome to the new (and completely empty) Grenade Sandwich. My name is Steven Merrill, a classical singer and technologist, and I'll be your host.

    » Continue reading this article.