Skip to content

Instantly share code, notes, and snippets.

@matthewjackowski
Created February 9, 2014 13:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewjackowski/8899134 to your computer and use it in GitHub Desktop.
Save matthewjackowski/8899134 to your computer and use it in GitHub Desktop.
Octopress Vagrant - Chef setup

I really love Octopress (http://octopress.org/). The only problem is setting up a functional Ruby environment. I always seem to spend more time with Ruby than the project itself. So I built a vagrant/chef setup for it. Before I go too far...I assume you have the following setup (this is a non-trivial task, thats covered better elsewhere): Virtualbox, Vagrant, Vagrant Plugins (vbguest, omnibus, berkshelf)

Ok let's jump into some code for the Berkshelf:

cookbook "dmg", "<= 2.0.6"
cookbook "git"
cookbook "curl"
cookbook "rvm", git: 'https://github.com/fnichol/chef-rvm.git'

It's really important that you get the fnichol cookbook, it's awesome...and somewhat more importantly it allows you to install your ruby into vagrant user, so you don't fudge up the chef stuff already there.

Next is the provisioning piece, which is really pretty straightforward now that it's figured. It's important to note that you need the 'dev' version of ruby in order for native extensions to compile correctly.

Do not be tempted into trying to install a 'root' ruby. Rvm wasn't designed to handle this for a reason. Trust the guys who know alot about ruby. Plus you have a perfectly fine vagrant account to use.

  config.vm.provision :chef_solo do |chef|
    chef.add_recipe "rvm::vagrant" 
    chef.add_recipe "rvm::user"

    chef.json = {
      :rvm => {
        :user_installs => [
           {
              :user => "vagrant",
              :default_ruby => "1.9.3-dev",
              :rubies => ["1.9.3-dev"],
              :global_gems => [
                  { :name => 'bundler' }
              ]                  
           }
        ]
      }
    }
  end

I stopped here because your environment is setup for all purposes. You can now clone the project and run 'bundle install' to install it.

Also note if you want to use Octopress 'rake deploy', you will need to setup Git from within vagrant. I didn't do this since it likely involves spamming my ssh keys in config files or data bags. I just cloned my repo to the /public location and do pushes from my host computer. ####Creds

:octocat:fin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment