<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[]]></title>
  <link href="/atom.xml" rel="self"/>
  <link href="/"/>
  <updated>2012-05-08T12:41:04-07:00</updated>
  <id>/</id>
  <author>
    <name><![CDATA[]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Chef: Cooking with Gas]]></title>
    <link href="/blog/2012/04/01/chef-cooking-with-gas"/>
    <updated>2012-04-01T00:00:00-07:00</updated>
    <id>/blog/2012/04/01/chef-cooking-with-gas</id>
    <content type="html"><![CDATA[<p>All the cool kids are talking about &#8220;devops&#8221; these days. The idea means many things to many people, but one thing just about everyone agrees upon is taking an automated, iterative, reproducible approach to your infrastructure. In practice, this means using a configuration management system. <a href='http://www.opscode.com/chef/'>Chef</a> and <a href='http://puppetlabs.com/puppet/puppet-open-source/'>Puppet</a> are the two big names in this space recently. We use Puppet at TeamSnap; we don&#8217;t have absolutely every part of our platform defined in Puppet, but we&#8217;re working on it. <!-- more --> At this year&#8217;s <a href='http://www.rubynation.org/'>RubyNation</a> conference I saw a talk by CustomInk&#8217;s Nathen Harvey called <a href='https://github.com/nathenharvey/cooking-with-chef'>The Joy of Cooking: Whip up a Rails Environment with Chef</a>. Nathen gave a good introduction to the concepts of Chef, and it got me thinking about looking more into Chef.</p>

<p>One thing Nathen said in his talk, and that I&#8217;ll repeat here, is that Chef isn&#8217;t necessarily &#8220;better&#8221; than Puppet, or vice versa. If your team already uses one, there&#8217;s no need to switch to the other. Puppet was already well established at TeamSnap when I joined the team there, so I&#8217;m not pushing a move to Chef. My interest in Chef is more to satisfy my own curiosity.</p>

<p>And speaking of which, if you have a small application that runs comfortably on one server, Chef and Puppet are overkill. In fact, running your own server is probably overkill, too. Consider using <a href='http://www.heroku.com/'>Heroku</a> in this case. Seriously, Heroku&#8217;s a great product, and pretty affordable for small applications that don&#8217;t need a lot of extras. And you won&#8217;t need to worry about administering your platform at all.</p>

<p>Over the past several days, I&#8217;ve been messing around with Chef for some of my own servers, and although I&#8217;m not going to give a full tutorial here, I&#8217;ll share some advice from my experience.</p>

<p>First, I really recommend using <a href='http://www.opscode.com/hosted-chef/'>Hosted Chef</a>, especially if you&#8217;re just starting out. Installing your own Chef server is not particularly difficult if you use Debian/Ubuntu packages, but it pulls in a <em>lot</em> of stuff, and unless you&#8217;re already an expert in everything it depends on (CouchDB, RabbitMQ, etc.) you&#8217;re going to basically be left with a black box anyway. In that case, you might as well let someone else manage the black box for you. You get five nodes for free with Hosted Chef, making it a great option for the first-time Chef experimenter. So skip the Chef Server set up and spend your time on actually using Chef!</p>

<p>Even if you do set up your own Chef server, it&#8217;s probably a good idea not to set it up on the same network or cloud as the servers it&#8217;ll be managing. It&#8217;s not very likely that Amazon or Rackspace will disappear tomorrow, but if they do, and your Chef server is there along with all your production servers, you&#8217;ll be starting over from nothing. Keeping your Chef server elsewhere (or using Hosted Chef) would make rebuilding from bare metal a lot easier in this case. (If you&#8217;re concerned about traffic, don&#8217;t be; my experience so far is that Chef doesn&#8217;t hog much bandwidth after you&#8217;ve bootstrapped a new node, and even the bootstrap isn&#8217;t too heavy.)</p>

<p>Once you&#8217;ve got your Hosted Chef or Chef server going, start looking for cookbooks. The Opscode Community is your one-stop shop for this. <a href='http://community.opscode.com/'>Take a look around</a>; it&#8217;s very likely that you&#8217;ll find cookbooks for just about every part of your platform, including app servers, database servers, mail servers, random other bits you depend on, and so on. <em>Don&#8217;t reinvent wheels!</em> The cookbooks you get here will almost certainly do what you want. If they don&#8217;t, you can fork them and adjust to taste. But you should definitely build upon what&#8217;s out there rather than starting from scratch.</p>

<p>That said, you&#8217;ll probably want to write your own cookbook at some point, to handle the little nuances and other local preferences that you have. Before you do that, read up on recipes and resources at the <a href='http://wiki.opscode.com/display/chef/Home'>Chef wiki</a>. Ruby hackers will feel right at home with Chef&#8217;s DSL, and once you&#8217;ve got a grip on using recipes and resources, you&#8217;ll have no problem assembling your custom cookbook.</p>

<p>Knife, Chef&#8217;s command-line tool, is pretty easy to learn, and you&#8217;ll be using it extensively. You can edit many of Chef&#8217;s data structures, such as roles and data bags, through Knife. One gotcha you&#8217;ll probably run into is if you use an editor that forks by default, like MacVim or TextMate, Knife will not wait for you to finish with the editor. Git also exhibits this behavior, so you&#8217;ve probably seen it before. You&#8217;ll need to either change the <code>EDITOR</code> in your environment to something that doesn&#8217;t fork (I use <code>mvim +0 -f --nomru</code>) or pass that something to Knife using the -e switch. It&#8217;d be nice if Knife respected a separate <code>KNIFE_EDITOR</code> variable, or allowed the editor to be defined in its configuration, as GIt does. But it&#8217;s not so hard to work around once you know what&#8217;s happening.</p>

<p>I&#8217;ll be working more with Chef in the coming days and weeks, so I&#8217;ll likely have more to say then, but at this point I&#8217;ve managed to define a lot of infrastructure in Chef, to the point where I can bring up a new server (including provisioning the new cloud instance) with a single command. As an inexplicably-famous hotel heiress once said, that&#8217;s hot.</p>

<p>Stay tuned for more in the future&#8230;</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Upgrading to Rails 3]]></title>
    <link href="/blog/2012/01/14/upgrading-to-rails-3"/>
    <updated>2012-01-14T00:00:00-08:00</updated>
    <id>/blog/2012/01/14/upgrading-to-rails-3</id>
    <content type="html"><![CDATA[<p>At <a href='http://www.teamsnap.com/'>TeamSnap</a>, we&#8217;re preparing to upgrade our code base from Rails 2 to Rails 3. To get some practice with this, I&#8217;ve been working on updating the <a href='http://klang.org/'>Klang</a> app that I maintain. <!-- more --> The guys at Airbnb have <a href='http://nerds.airbnb.com/upgrading-airbnb-from-rails-23-to-rails-30'>an excellent account</a> of their own experience. All of their advice is very good. I was lucky in that I had already done step 1 (move to Bundler) and step 2 (add the <code>rails_xss</code> plugin) - in fact, I did <code>rails_xss</code> about two years ago, when I thought I would get to the rest of the Rails 3 upgrade soon. That didn&#8217;t happen, but it did mean a lot of the really hard work was done when I started the upgrade in earnest.</p>

<p>There were tons of deprecated features that I had to address. Most of them were no big deal. Learning <a href='http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3'>the new ActionMailer API</a> took a bit of head-wrap-around, but in the end it wasn&#8217;t a problem. The biggest problem was that <a href='https://github.com/thoughtbot/shoulda'>Shoulda</a> just failed horribly in all of my functional tests (yes, I&#8217;m still using good old Test::Unit, not rspec - that&#8217;s a paradigm shift for another day.) The unit tests were fine, but the functional tests that had run perfectly under Rails 2 broke inconsistently under Rails 3. In the end, I ended up rewriting the functional tests to not use Shoulda, and ran those tests instead. When everything else was working, I put the Shoulda-fied tests back in, and they worked fine. I spent a few hours de-Shoulda-fying the tests, but I&#8217;ll chalk it up to a useful learning exercise.</p>

<p>One thing that bit me was several of my &#8220;destroy&#8221; links on the admin side simply failed to work. This was my own damn fault; I should&#8217;ve been using form submissions to do these all along. As often happens, Stack Overflow <a href='http://stackoverflow.com/questions/4606860/rails-3-link-to-to-destroy-not-working'>pointed me in the right direction</a> and I replaced all the <code>link_to</code>s with <code>button_to</code>s. That fixed that.</p>

<p>So at this point, I&#8217;ve got the application running on Rails 3.0, with all of the tests passing, and it works well in development mode on <a href='http://pow.cx/'>Pow</a>. The next step will be uploading this to a new app on <a href='http://www.heroku.com/'>Heroku</a>, alongside our existing Rails 2 app, and pounding on it for a while. But it all looks good right now.</p>

<p>Once this is done, moving to Rails 3.1 is the next step. We don&#8217;t do a lot of JavaScript at Klang, but we&#8217;ve got some, so the asset pipeline is likely to be our biggest challenge. And from there, who knows&#8230; maybe we&#8217;ll all be on Rails 4 by then?</p>]]></content>
  </entry>
  
</feed>

